PC Rental Application.

Here is what I ended up with. Can I ask a couple of questions?

First, why does my timer run only when I press enter. 1 Enter = 1 Second.

Second, Why can't I esc to the main menu when the timer is doing its thing.

Third, How can I set the time for a computer, go back to the main menu, set the time for another computer, then back to the main menu, then when I go back to the first computer I set the time for, the time should still be running, that it wouldn't revert back to 0:0:0

Lastly, how can I forcefully stop the time. As in the time only stops whenever I want it to stop.

Any help would be appreciated very much.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#include <iostream.h>
#include <conio.h>
#include <windows.h>
#include <stdlib.h>

void type1(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\n\t\tEnter the current hour   ----> ";
    cin >> h;

    cout << "\n\t\tEnter the current minute ----> ";
    cin >> m;

    cout << "\n\t\tEnter the current second ----> ";
    cin >> s;


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

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

          cout<<"\n\n\t\t[PRESS ESC TO STOP TIME AND GO BACK TO THE MAIN MENU]";
          cout<<"\n\n\t\t\t   [PRESS ENTER TO START TIME]";

          cout<<"\n\n\n\n\n\t\tTime started : ";
          cout<<"\t\t\t"<<h<<":"<<m<<":"<<s;

          cout<<"\n\n\n\t\tTime now     : ";
          cout<<"\t\t\t"<<h2<<":"<<m2<<":"<<s2;

          cout<<"\n\n\n\t\tTime occupied: ";
          cout<<"\t\t\t"<<h1<<":"<<m1<<":"<<s1;

          cout<<"\n\n\n\t\tFee to pay    : ";
          cout<<"\t\t"<<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\n\t\t\t   PC RENTAL APPLICATION";
getch();
cout<<"\n\n\n\n\n\n\n\t\t\tPRESS ENTER TO CONTINUE";
cout<<"\n\n\t\t\tPRESS ESC TO EXIT";

ans = getch();

if (ans==13)
{
type1();
}

if (ans==27)
{
}
}



void type1(void)
{
	 dforce f;
    char code;

    rep:
    clrscr();
    cout<<"\n\n\t\t\t  DragonForce Computer Shop";
    getch();
    cout<<"\n\n\t\t\t   RATE: 1 PHP = 1 MINUTE";
    getch();
    cout<<"\n\n\t*We know the price is high. So we got the actual band to perform";
    getch();
    cout<<"\n\n\n\t\t\t     --PCs Available--";
    cout<<"\n\n\n\t\t\tPC[1]\t\t\tPC[2]";
    cout<<"\n\n\t\t\tPC[3]\t\t\tPC[4]";
    cout<<"\n\n\t\t\tPC[5]\t\t\tPC[6]";
    cout<<"\n\n\t\t\tPC[7]\t\t\tPC[8]";
    cout<<"\n\n\t\t\tPC[9]\t\t\tPC[0]";
    cout<<"\n\n\t[Enter PC # you wish to activate or Enter x if you want to exit]";
    cout<<"\n\n\n\t\tEnter choice here --> ";
    cin>>code;

    if (code == 'x' || code == 'X')
    {
    goto exit;
    }

    clrscr();

    switch(code)
    {
    case '1': cout<<"\n\n\n\n\n\n\n\t\t\t--PC NUMBER 1 ACTIVATED--";
    			  cout<<"\n\t\t\t(Press any key to continue)";
              f.work();break;

    case '2': cout<<"\n\n\n\n\n\n\n\t\t\t--PC NUMBER 2 ACTIVATED--";
    			  cout<<"\n\t\t\t(Press any key to continue)";
              f.work();break;

    case '3': cout<<"\n\n\n\n\n\n\n\t\t\t--PC NUMBER 3 ACTIVATED--";
    			  cout<<"\n\t\t\t(Press any key to continue)";
              f.work();break;

    case '4': cout<<"\n\n\n\n\n\n\n\t\t\t--PC NUMBER 4 ACTIVATED--";
    			  cout<<"\n\t\t\t(Press any key to continue)";
              f.work();break;

    case '5': cout<<"\n\n\n\n\n\n\n\t\t\t--PC NUMBER 5 ACTIVATED--";
    			  cout<<"\n\t\t\t(Press any key to continue)";
              f.work();break;

    case '6': cout<<"\n\n\n\n\n\n\n\t\t\t--PC NUMBER 6 ACTIVATED--";
    			  cout<<"\n\t\t\t(Press any key to continue)";
              f.work();break;

    case '7': cout<<"\n\n\n\n\n\n\n\t\t\t--PC NUMBER 7 ACTIVATED--";
    			  cout<<"\n\t\t\t(Press any key to continue)";
              f.work();break;

    case '8': cout<<"\n\n\n\n\n\n\n\t\t\t--PC NUMBER 8 ACTIVATED--";
    			  cout<<"\n\t\t\t(Press any key to continue)";
              f.work();break;

    case '9': cout<<"\n\n\n\n\n\n\n\t\t\t--PC NUMBER 9 ACTIVATED--";
    			  cout<<"\n\t\t\t(Press any key to continue)";
              f.work();break;

    case '0':cout<<"\n\n\n\n\n\n\n\t\t\t--PC NUMBER 0 ACTIVATED--";
    			  cout<<"\n\t\t\t(Press any key to continue)";
              f.work();break;

    default : cout<<"\n\n\n\t\t\tINVALID PC #. PLEASE TRY AGAIN ";
    			  goto rep;

              exit:
    }
}


Topic archived. No new replies allowed.