hi guys,
Below is my program and it is giving me turf time.I want it to read-in 1-for counting cars,2-for counting money and Esc-key for displaying totals.Pliz give me ideas.(i'm using Microsoft-visual c++)
#include <iostream>
using namespace std;
#include <conio.h>
class tollBooth
{
private:
unsigned int cars;
double money;
public:
tollBooth() : cars(0), money(0)
{ }
void payingCar();
void nopayCar();
void display() const;
};
void tollBooth::payingCar()
{
cars++;
money+=0.5;
}
void tollBooth::nopayCar()
{
cars++;
}
void tollBooth::display() const
{
cout << "Total cars = " << cars <<"\n\n"<< " Total money = " << money;
}
int main()
{
tollBooth R;
char chrt= ' ';
cout << "Press '1' for paying cars and '2' for non-paying cars : " <<
endl;
cin>>chrt;
while (chrt !='3')
{
chrt = getch();
switch (chrt)
{
case '1':
R.payingCar();
break;
case '2':
++money;
R.nopayCar();
break;
default:
cout<<"should not be here : ";
cin>>chrt;
}
}
R.display();
return 0;
}