I want to make a stopwatch with these keyboard function

Details:
I want to make a stopwatch with these keyboard function;
1. s (start/stop)
3. p (pause)
3. r (reset)

 

Can u fix it for me ?

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

**Addtional code :**

#include<iostream>
#include<conio.h>
#include<windows.h>
using std::cout;

int main (){
for(int i=9; i>=0; i–){
if(kbhit()){
auto got=getch();
if(got==’p’||got==’P’){
cout<<“PAUSED, R to resume.\b”;
do auto got=getch(); while(got!=’r’&&got!=’R’);
}
}
cout << i << ‘\b’;
Sleep(1000);
}
do; while(getch()!=’\n’);
}

——————————————————————————————————————————————————————————————————————————————————————

**And here is the main code :**

#include<conio.h>
#include<process.h>
#include<iostream>
#include<windows.h>
using namespace std;
using std::cout;

void gotoxy(int column, int line);
void time(int milisecs, int secs, int mins, int hours);
void display();
int milisecs = 0, secs = 0, mins = 0, hours = 0;

int main()
{

int a;
display();

for (a = 16; a <= 63.4; a++)
{
gotoxy(a, 4.3);
std::cout << char(220);
}

for (a = 63.4; a >= 16.4; a–)
{
gotoxy(a, 13);
std::cout << char(220);
}

for (a = 13.4; a >= 5; a–)
{
gotoxy(16, a);
std::cout << char(219);
}

for (a = 5.4; a <= 13; a++)
{
gotoxy(63.4, a);
std::cout << char(219);
}

while (true)
{
// display mili-second
gotoxy(59, 10);

if (milisecs < 10)
{
std::cout << “0”;
}
std::cout << milisecs;

// display second
gotoxy(39, 10);
if (secs < 10)
{
std::cout << “0”;
}
std::cout << secs <<“:”;

// display mins
gotoxy(29, 10);
if (mins < 10)
{
std::cout << “0”;
}
std::cout << mins << “:”;

// display hours
gotoxy(21, 10);
if (hours < 10)
{
std::cout << “0”;
}
std::cout << hours << “:”;

if (hours == 24)
{
break;
}

milisecs++;

if (milisecs >= 60)
{
secs++;
milisecs = 0;
}

if (secs >= 60)
{
mins++;
secs = 0;
}

if (mins >= 60)
{
hours++;
mins = 0;
}

Sleep(5);

if(kbhit())
{
auto got=getch();
if(got==’p’||got==’P’)
{
cout<<“PAUSED, R to resume.\b”;
do auto got=getch(); while(got!=’r’&&got!=’R’);
}
}
cout << time(int milisecs, int secs, int mins, int hours) << ‘\b’;
Sleep(1000);

if(kbhit())
{
auto got=getch();
if(got==’p’||got==’P’)
{
do auto got=getch(); while(got!=’p’&&got!=’P’);
}
}

}
return 0;
}

void gotoxy(int column, int line)
{
COORD coord;
coord.X = column;
coord.Y = line;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

void display()
{
int clrscr();
gotoxy(16.4, 1);
std::cout <<“********************************************” <<endl;
gotoxy(16.4, 2);
std::cout <<“**************** STOPWATCH BETA ************” <<endl;
gotoxy(16.4, 3);
std::cout <<“********************************************” <<endl;

gotoxy(18.4, 6);
std::cout << “| Hours |”;

gotoxy(26.4, 6);
std::cout << “| Minuets |”;

gotoxy(36.4, 6);
std::cout << “| Seconds |”;

gotoxy(46.4, 6);
std::cout << “| Mili-Seconds |”;

}

——————————————————————————————————————————————————————————————————————————————————————

Errors code :

——————–Configuration: ETA – Win32 Debug——————–
Compiling…
ETA.CPP
C:\Users\7\Desktop\ETA\ETA\ETA.CPP(122) : error C2144: syntax error : missing ‘)’ before type ‘int’
C:\Users\7\Desktop\ETA\ETA\ETA.CPP(122) : error C2660: ‘time’ : function does not take 0 parameters
C:\Users\7\Desktop\ETA\ETA\ETA.CPP(122) : error C2059: syntax error : ‘)’
Error executing cl.exe.

ETA.exe – 3 error(s), 0 warning(s)

——————————————————————————————————————————————————————————————————————————————————————
Your Reply,
Thanks

TK Ditanyakan on 15 July 2018 pada Windows.
Tambah Komentar
0 Jawaban
  • Jawaban Anda

    Dengan memposting jawaban, anda setuju dengan Kebijakan Privasi dan ketentuan layanan.