Hi, you guys helped me on a program about a month ago and it really helped me get through the program. Therefore I really appreciate what you all do and thank you for the help last time
I am having trouble finishing this program on classes the assignment is this:
Write a program to simulate a tollbooth at a bride. Cars passing by the booth are expected to pay a fifty cent toll. Mostly the cars do, but some cars go without paying. The tollbooth keeps a track of the number of cars that have gone by, and the total money collected.
Model this tollbooth with a class tollbooth. The two data items are of type int to hold the total number of cars and type float to hold the total amount of money collected.
A constructor initializes both these items to 0.
A member function called payingCar() increments the car total and adds 0.50 to the cash total.
Second member function called nopayCar() increments the car total but adds nothing to the cash total.
Finally a member function display() displays the two total.
This is what I have so far:
# include <iostream>
# include <iomanip>
using namespace std;
// Class declaration
Tollbooth (int = 0, float = 0); // constructor
void payingCar (int, float); // Function to increment the car total and cash total by 0.50
void nopayCar(int); //Function to increment the car total, but not cash total.
void display(); //Function to display the two member variables
// implementation section
Tollbooth::Tollbooth(int num, float num1)
cartotal = num;
cash = num1;
void Tollbooth::payingCar(int num, float num1)
num1 = num1 + 0.50;
void Tollbooth::nopayCar(int num)
cout << "\nNumber of cars gone by: " << num << endl;
cout << "Total money collected: " << num1 << endl;
cout<<"press 0 for non-paying cars / press 1 for paying cars / press Esc to exit program";
toll.payingCar();//call appropriate function
toll.nopayCar();// write functionality;
} while(ch != ESC);
The problem is that I am getting six errors and I am at a lost as to how to fix them.
These are the errors:
Warning 1 warning C4244: '=' : conversion from 'double' to 'float', possible loss of data \
Error 2 error C2065: 'num' : undeclared identifier
Error 3 error C2065: 'num1' : undeclared identifier
Error 4 error C3861: 'getche': identifier not found
Error 5 error C2660: 'Tollbooth::payingCar' : function does not take 0 arguments
Error 6 error C2660: 'Tollbooth::nopayCar' : function does not take 0 arguments
Error 7 error C2065: 'ESC' : undeclared identifier
Anything will help, Thank you.