Question: Q1. Construct a class named tollBooth that models a toll booth. It should include integer data members paidCars, nonpaidCars, totalCash, a constructor that initialize these
Q1. Construct a class named tollBooth that models a toll booth. It should include integer data members paidCars, nonpaidCars, totalCash, a constructor that initialize these data members to 0, and three member functions pCar(), npCar(), and display(). pCar() should increment the paidCars while npCar() should increment the nonpaid Cars data members respectively, while display() should display the number of paid Cars, non paidCars and total Cash.. In main() these functions should be called repeatedly in a loop depending on a condition. If 0 is pressed then a car is passed and a toll tax of Rs. 150/- is paid. If 1 is pressed then a car is passed without paying tax. If 2 is pressed then exit the program and display total number of cars which have paid tax and total cars which have not paid and the total amount of tax collected i.e. total Cash.
Q2. How the private data members of a class are accessed outside the class? Explain with suitable example.
oops in c++ language
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
