question archive 1)Imagine a tollbooth at a bridge

1)Imagine a tollbooth at a bridge

Subject:Computer SciencePrice: Bought3

1)Imagine a tollbooth at a bridge. Truckspassing by the booth are expected to pay a 100 cent toll. Mostly they do, but sometimes a truck

goes by without paying. The tollbooth keeps track of the

number of trucks that have gone by, and of the total amount of money collected.

Model this tollbooth with a

class called tollBooth. The two

data items are a type

int

to hold the total

number of trucks

, and a type double to hold the total amount of money collected.

A constructor initializes both of these to 0. A member function called payingCar() increments the

truck

total and adds 100

to the cash total. Another function, called nopayCar(), increments the truck

total but adds nothing to the cash total. Finally, a member function called display() displays the two

totals. Make appropriate member functions const.

Include a program to test this class. This program should allow the user to push one key to count a

paying car, and another to count a nonpaying car. Pushing the Esc key should cause the program to

print out the total cars and total cash and then exit.

Note:

The ASCII

code for Esc key is 27.

You can make use of

_getche()

for taking input from user

for their choice of operation.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE