}
if (m2 > 59)
{
m2 = 0;
h2++;
}
if (h2 > 24)
{
h2 = 0;
}
if (h1 > 24)
{
h1 = 0;
}
}
}
I'm having trouble running the timer/clock because when I put an if else before the end of the code like.
if (ans == 'y' || ans == 'Y')
goto rep;
the timer/clock won't function anymore. it only functions when i enter 'n' but then it will only run as many times as the 'n's I enter. and if I enter 'n' it would not let me enter anything else. It would only let me enter something else after it has run it's function. Would appreciate any help.
Okay. So I also don't get what your asking because as I have said. I ,still, am just a beginner. But instead. Let me just ask you. How would you do this for yourself. You need to make an application which will allow the user to monitor the time that his customers have used and how much they should pay. Basically, this is a PC Rental app. You should have a loop which will take you back to the main menu.
How can I make something appear when I press the escape button. Like when I press the escape button, that's the only time my "Do you want to go back to the main menu" would show up.
And another question.
How can I keep the timer/clock running while i'm on the main menu. So that, when I go to the main menu, the timer/clock would still be running and when I come back, it still is running.
Last question.
If the "other question" is solved. How can I stop the time and end the program.
For getting the current time (to the second) use time(NULL) found in <ctime>.
As for capturing each key press, don't go there. It's much easier to deal with you standard input stream cin (which normally comes from the keyboard) then to try to capture a key press event.
cout<<"\n\nPC RENTAL APPLICATION";
cout<<"\n\nCREATED BY: ME";
cout<<"\n\nPRESS ENTER TO CONTINUE";
cout<<"\n\nPRESS ESC TO EXIT";
ans = getch();
if (ans==13)
{
type1();
}
if (ans==27)
{
}
}
void type1(void)
{
dforce f;
char code;
rep:
clrscr();
cout<<"\n\n\DragonForce Computer Shop";
cout<<"\n\nRATE: 1 PHP = 1 MINUTE";
cout<<"\n\nPCs Available";
cout<<"\n\n\nPC[1]\t\tPC[2]";
cout<<"\n\nPC[3]\t\tPC[4]";
cout<<"\n\n[Enter PC # you wish to activate or Enter x if you want to exit]";
cout<<"\n\n\nEnter choice here --> ";
cin>>code;
if (code == 'x' || code == 'X')
{
goto exit;
}
clrscr();
switch(code)
{
case '1': cout<<"\n\n\n\n\n\n\n--PC NUMBER 1 ACTIVATED--";
cout<<"\n(Press any key to continue)";
f.work();break;
case '2': cout<<"\n\n\n\n\n\n\n--PC NUMBER 2 ACTIVATED--";
cout<<"\n(Press any key to continue)";
f.work();break;
case '3': cout<<"\n\n\n\n\n\n\n--PC NUMBER 3 ACTIVATED--";
cout<<"\n(Press any key to continue)";
f.work();break;
case '4': cout<<"\n\n\n\n\n\n\n--PC NUMBER 4 ACTIVATED--";
cout<<"\n(Press any key to continue)";
f.work();break;
default : cout<<"\n\n\nINVALID PC. PLEASE TRY AGAIN ";
goto rep;
exit:
}
}
I know it looks messy. Don't point out the obvious.
As for my problem.
How can I keep the timer/clock running while i'm on the main menu. So that, when I go to the main menu, the timer/clock would still be running and when I come back, it still is running on that PC. For example. I activated the timer/clock on PC1. How can I move to the main menu without ending the "timing" and lastly, how can I stop that "timing".