Math, asked by mannysingh3730, 1 year ago

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 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 unsigned int to hold the total number of cars, and a type double to hold the total amount of money collected.

Answers

Answered by vaduz
0

let total collection is "GT"

so total no of cars who paid the toll "PC" =GT/50

let recorded total cars who passed from tollbooth=C

so no of cars who did not paid the toll "UC"= C-PC

from this process you will get all the data clearly.


Answered by deepkaria0
2

Answer:

C++ Code Of The Question

#include <iostream>

const char ESC=27;

const double toll=0.5;

using namespace std;

class tollbooth

{

int NoOfCars;

float AmountOfMoney;

public:

tollbooth()

{

NoOfCars=0;

AmountOfMoney=0.0;

}

void payingcar();

void nonpayingcar();

void show();

};

void tollbooth::payingcar()

{

AmountOfMoney+=toll;

NoOfCars++;

}

void tollbooth::nonpayingcar()

{

NoOfCars=NoOfCars+1;

}

void tollbooth::show()

{

cout<<"Number Of Cars : " << NoOfCars << endl;

cout<<"Amount : " <<AmountOfMoney<<endl;

}

int main()

{

char n;

tollbooth t1;

cout<<"Press '0' For Paying Car, '1' For Non Paying Car and 'ESC' For Result"<<endl;

do

{

cin>>n;

if(n=='0')

{

t1.payingcar();

}

if(n=='1')

{

t1.nonpayingcar();

}

}

while(n!=ESC);

{

t1.show();

}

}

Similar questions