Question: 3. 150] Tollbooth class - Write a complete program. Imagine a tollbooth at a bridge. Cars passing by the booth are expected to pay a

 3. 150] Tollbooth class - Write a complete program. Imagine a

3. 150] Tollbooth class - Write a complete program. 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 o. 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 andq, should cause the program to print out the total number of cars and total amount collected. Save this program as lab12b.cc Sample output of this program can be as follows (user input in italics): P paid N Not paid Quit -p P paid N Not paid Q Quit - p P paid N Not paid Quit -> n P paid N Not paid Quit -p P paid N Not paid Q Quit -> n P paid N Not paid Q Quit -q Total number of cars 5 Total amount collected $1.50

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!