Practise Problems..
Practise Problems..
#include<conio.h>
class Tollboth {
int cars;
double cash;
public:
Tollboth()
cars = 0;
cash = 0;
void paycar()
cars++;
cash += 0.50;
void nopaycar()
cars++;
void display()
cout << "The total cars which have passed through the tollboth are: " << cars << endl;
};
int main()
{
Tollboth T1;
int i = 0;
cout << "Press escape to show all the results and exit: " << endl;
while (true)
int choice;
choice = _getch();
if (choice == 13)
T1.paycar();
i++;
T1.nopaycar();
i++;
system("cls");
T1.display();
}
return 0;
2)
#include<iostream>
class Time
public:
Time()
hours = 0;
minutes = 0;
seconds = 0;
int h, m, s;
h = x.hours + y.hours;
m = x.minutes + y.minutes;
s = x.seconds + y.seconds;
while (true)
{
if (m > 59)
h += 1;
m -= 60;
if (s > 59)
m += 1;
s -= 60;
continue;
else
break;
};
int main()
Time t3;
t3.display(t1,t2);
return 0;