Assistance needed with my PC Rental Application.

Well this is as far as I got. I know it looks messy but please bear with me. I'm still just a beginner.


#include <iostream.h>
#include <conio.h>
#include <windows.h>
#include <stdlib.h>

void type1(void);
void type12(void);

class dforce
{
public:

void work(void)
{
int h,m,s;
int h1=h, m1=m, s1=s;
int h2,m2,s2;
int fee = 0;
int a = 0;
unsigned pw;
char ans;

pw=getch();
rep:
cout << "\n\n\nEnter the current hour --> ";
cin >> h;

cout << "\nEnter the current minute --> ";
cin >> m;

cout << "\nEnter the current second --> ";
cin >> s;

h2=h;
m2=m;
s2=s;

while(a == 0)
{
system("cls");

cout<<"\n\n[PRESS ESC TO GO BACK TO THE MAIN MENU]";

cout<<"\n\n\nTime started: ";
cout <<h<<":"<<m<<":"<<s;

cout<<"\n\n\nTime now: ";
cout<<h2<<":"<<m2<<":"<<s2;

cout<<"\n\n\nTime occupied: ";
cout<<h1<<":"<<m1<<":"<<s1;

cout<<"\n\n\nFee to pay: ";
cout<<fee<<" PHP";

pw = getch();
if (pw==27)
{
type1();
;break;
}

Sleep(1000);
s1++;
s2++;


if (s1 > 59)
{
s1 = 0;
m1++;
fee++;
}
if (s2 > 59)
{
s2 = 0;
m2++;
}

if (m1 > 59)
{
m1 = 0;
h1++;

}
if (m2 > 59)
{
m2 = 0;
h2++;
}
if (h2 > 24)
{
h2 = 0;
}
if (h1 > 24)
{
h1 = 0;
}
endl;
};
};
};


void main(void)
{
unsigned ans;

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:
}
}

Sorry for not using [code] and all of those. I don't know how to use them in the forum.

Now to my problems.

First, I do not know why my timer/clock needs me to press enter just for it to add 1 second.

Next, I do not know why I can't press esc when my timer/clock is doing it's function.

Third, how can I start the timer for a PC go to the main menu start the time for a different PC then go back to the menu then when I go back to the first PC I have set the time for, the time shouldn't go back to 0. It should still be running.

Lastly, how can I forcefully stop the clock so that when I press a certain key. The timer would go back to 0.
Last edited on
Topic archived. No new replies allowed.