Question and Answers Forum

All Questions      Topic List

Others Questions

Previous in All Question      Next in All Question      

Previous in Others      Next in Others      

Question Number 15311 by arnabpapu550@gmail.com last updated on 09/Jun/17

In a toll-booth at a bridge , some cars can pass by paying a tax of Rs. 10 and  some special vehicles are exempted from paying tax. The booth has to track   number of vehicles and total tax collected. Define a class ′tollbooth′. It should contain  two data items of type int to hold the number of cars and total tax connected.  A constructor initalizes these two variable to zero. A memberfunction freecar() only  increments the car total. Finally another memberfunction show() displays the  two totals.     Write a C++ program such that the user has to press the key ′T′ for  printing number of taxable cars and total tax, ′F′ for printing number of  free  cars and ′Esc′ to exit.

$$\mathrm{In}\:\mathrm{a}\:\mathrm{toll}-\mathrm{booth}\:\mathrm{at}\:\mathrm{a}\:\mathrm{bridge}\:,\:\mathrm{some}\:\mathrm{cars}\:\mathrm{can}\:\mathrm{pass}\:\mathrm{by}\:\mathrm{paying}\:\mathrm{a}\:\mathrm{tax}\:\mathrm{of}\:\mathrm{Rs}.\:\mathrm{10}\:\mathrm{and} \\ $$$$\mathrm{some}\:\mathrm{special}\:\mathrm{vehicles}\:\mathrm{are}\:\mathrm{exempted}\:\mathrm{from}\:\mathrm{paying}\:\mathrm{tax}.\:\mathrm{The}\:\mathrm{booth}\:\mathrm{has}\:\mathrm{to}\:\mathrm{track}\: \\ $$$$\mathrm{number}\:\mathrm{of}\:\mathrm{vehicles}\:\mathrm{and}\:\mathrm{total}\:\mathrm{tax}\:\mathrm{collected}.\:\mathrm{Define}\:\mathrm{a}\:\mathrm{class}\:'\mathrm{tollbooth}'.\:\mathrm{It}\:\mathrm{should}\:\mathrm{contain} \\ $$$$\mathrm{two}\:\mathrm{data}\:\mathrm{items}\:\mathrm{of}\:\mathrm{type}\:\mathrm{int}\:\mathrm{to}\:\mathrm{hold}\:\mathrm{the}\:\mathrm{number}\:\mathrm{of}\:\mathrm{cars}\:\mathrm{and}\:\mathrm{total}\:\mathrm{tax}\:\mathrm{connected}. \\ $$$$\mathrm{A}\:\mathrm{constructor}\:\mathrm{initalizes}\:\mathrm{these}\:\mathrm{two}\:\mathrm{variable}\:\mathrm{to}\:\mathrm{zero}.\:\mathrm{A}\:\mathrm{memberfunction}\:\mathrm{freecar}\left(\right)\:\mathrm{only} \\ $$$$\mathrm{increments}\:\mathrm{the}\:\mathrm{car}\:\mathrm{total}.\:\mathrm{Finally}\:\mathrm{another}\:\mathrm{memberfunction}\:\mathrm{show}\left(\right)\:\mathrm{displays}\:\mathrm{the} \\ $$$$\mathrm{two}\:\mathrm{totals}. \\ $$$$\:\:\:\mathrm{Write}\:\mathrm{a}\:\mathrm{C}++\:\mathrm{program}\:\mathrm{such}\:\mathrm{that}\:\mathrm{the}\:\mathrm{user}\:\mathrm{has}\:\mathrm{to}\:\mathrm{press}\:\mathrm{the}\:\mathrm{key}\:'\mathrm{T}'\:\mathrm{for} \\ $$$$\mathrm{printing}\:\mathrm{number}\:\mathrm{of}\:\mathrm{taxable}\:\mathrm{cars}\:\mathrm{and}\:\mathrm{total}\:\mathrm{tax},\:'\mathrm{F}'\:\mathrm{for}\:\mathrm{printing}\:\mathrm{number}\:\mathrm{of}\:\:\mathrm{free} \\ $$$$\mathrm{cars}\:\mathrm{and}\:'\mathrm{Esc}'\:\mathrm{to}\:\mathrm{exit}. \\ $$

Terms of Service

Privacy Policy

Contact: info@tinkutara.com