Question: C++ program using classes. Thank you! Imagine a tollbooth at a bridge. Cars passing by the booth are expected to pay a 50 cent toll.
Imagine a tollbooth at a bridge. Cars passing by the booth are expected to pay a 50 cent toll. Mostly they do. but sometimes a car goes by without paying. The tollbooth keeps track of the number of cars that is gone by. and of the total amount of money collected. Model this tollbooth with a class called tollbooth. The two data member items are type int to hold the total number of cars, and type double to hold the total amount of money collected. A constructor initializes both of these to 0. A member function called payinCar () increments the car total and adds 0.50 to the cash total. Another function called nopayCar (), increments the car total but adds nothing to the cash total. Finally a member function called display (ostream& fileout) to displays the two totals to the screen. (Look at BankAccount class - pg 571-573) Make the stream parameters versatile (pg 346 - 347) Include a main function to test this class. The program should allow the user to enter 'p' to count a paying car. and 'n' to count a nonpaying car and 'q' should cause the program to print out the total number of cars and total amount collected. Save this program as label 2b. cc Sample output of this program can be as follows (user input in italics): Submit the programs electronically as labl2. Also print your answer sheet. Don't forget to do the documentation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
