#include<conio.h>
#include<process.h>
#include<iostream>
#include<dos.h>
using namespace std;
int h=0,m=0,s=0,ms=0; // Hours mins sec and microseconds
char ch='p'; //For Menu to start and pause stop watch
int main()
{
void watch(); // Build in Function of watch
watch();
while(1)
{
if(kbhit())
ch=getch();
if(ch=='s'||ch=='S')
break;
if(ch=='e'||ch=='E')
exit(0);
}
while(1)
{
watch();
if(kbhit())
ch=getch();
if(ch=='r'||ch=='R')
{
h=m=s=ms=0;
watch();
while(1)
{
if(kbhit())
ch=getch();
if(ch=='s'||ch=='S')
break;
if(ch=='e'||ch=='E')
exit(0);
}
}
else
if(ch=='p'||ch=='P')
while(1)
{
if(kbhit())
ch=getch();
if(ch=='s'||ch=='S')
break;
if(ch=='e'||ch=='E')
exit(0);
if(ch=='r'||ch=='R')
{
ch='c';
h=m=s=ms=0;
watch();
}
}
else
if(ch=='e'||ch=='E')
exit(0);
if(ms!=99)
ms++;
else
{
ms=0;
if(s!=59)
s++;
else
{
s=0;
if(m!=59)
m++;
else
{
m=0;
h++;
}
}
}
}
}
int watch()
{
system("cls");
cout<<"\n\n\n\n\n\t\t\t\t-------------";
cout<<"\n\t\t\t\t| Stopwatch |";
cout<<"\n\t\t\t\t-------------";
cout<<"\n\n\t\t\t\t "<<h<<":"<<m<<":"<<s<<":"<<ms;
cout<<"\n\t\t\t\t\t\t\t---------";
cout<<"\n\t\t\t\t\t\t\t Menu";
cout<<"\n\t\t\t\t\t\t\t---------";
cout<<"\n\t\t\t\t\t\t\ts -> Start";
cout<<"\n\t\t\t\t\t\t\tp -> Stop";
cout<<"\n\t\t\t\t\t\t\tr -> Reset";
cout<<"\n\t\t\t\t\t\t\te -> Exit";
}
This is a requested program you can also request a program
on our group on facebook join today
0 comments:
Post a Comment