Question

In: Computer Science

Imagine a tollbooth at a bridge. Cars passing by the booth are expected to pay a...

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. A constructor initializes both of these to 0. A member function called
payingCar() 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() displays the two totals.

Solutions

Expert Solution

code for the above problem given below:

#include<iostream>
using namespace std;
class tollBooth
{  
    private:                                              // data items declared as required
    unsigned int car;
    double money;
    
    public:
    tollBooth(): car(0), money(0) {}           // constructor calling to initialize car and money to 0
    void payingCar()                   // payingCar add 0.50 to money and add 1 to car inorder to count the cars passes by       
    {
         car=car+1;
         money=money+0.50;                                
    }
    void nopayCar()                   //  car passes but do not pay . therefore no money added 
    {
         car=car+1;
         money=money+0;
    }
    void display()
    {
          cout<<"\n Total Money Collected On TollBooth = "<<money<<endl;
          cout<<" Total cars On TollBooth = "<<car<<endl;
    }
    
};
 
int main()
{
       char n;
       tollBooth d;
       cout<<"Enter 1 For Toll Paying Cars and 2 For Non-Toll Paying Cars = ";
       
        cin>>n;
        switch (n)                                    // if entered 1 than payingCar information display else nopaying car info display
           {
               case '1':
                         d.payingCar();         // call to member functoin of tollBooth class
                         d.display();
                        
                         break;
                case '2':
                         d.nopayCar();
                         d.display();
                         
                         break;
           }
return 0;
}

sample output:


Related Solutions

Imagine that you are in a car that is traveling up a bridge that is inclined...
Imagine that you are in a car that is traveling up a bridge that is inclined at an angle of 4.0 degrees from the horizontal. The car's speed is 35.0 mi/hr (15.65 m/s). At time t = 0 you open your window and illegally drop a soda can from your rest frame over the edge of the bridge. Your height above ground level is 36.0 m. 1. How far does the can travel horizontally before hitting the ground? Neglect air...
A bridge on a small, rural road is designed to hold 10 cars when it is...
A bridge on a small, rural road is designed to hold 10 cars when it is full and its maximum continuous weight that the bridge is designed to hold is 39,000 pounds. Assume that the average American car weighs 3750 pounds and that American cars' weights have a standard deviation of 200 pounds. If the bridge is fully loaded with 10 cars, what is the probability that it will be overloaded? Hint: Think about what the bridge designer thought the...
The speed of cars passing through the intersection of Blossom Hill Road and the Almaden Expressway...
The speed of cars passing through the intersection of Blossom Hill Road and the Almaden Expressway varies from 12 to 35 mph and is uniformly distributed. None of the cars travel over 35 mph through the intersection. a. Enter an exact number as an integer, fraction, or decimal. μ = b. σ =  (rounded to two decimal places) c. What is the probability that the speed of a car is at most 26 mph? d. What is the probability that the...
2. Cars which are passing an automatic toll are modeled by a Poisson process with rate...
2. Cars which are passing an automatic toll are modeled by a Poisson process with rate of 10 cars per hour. Some cars may violate with the probability of 0.5. a. Calculate the probability that exactly 10 cars pass within an hour and all 10 have no violations? b. For any fixed x ≥ 10, find the probability that x cars pass during the hour, of which 10 have no violations?
A traffic engineer believes that the number of cars passing through a certain intersection between 2...
A traffic engineer believes that the number of cars passing through a certain intersection between 2 and 6 pm on weekdays follows a normal distribution with mean 750 and standard deviation 100. A new highway is opened, and it is hypothesized that the number or cars passing through the intersection should decrease as a result. A sample of 15 weekdays is taken, and the mean number of cars passing through the intersection is 710. Decide whether this reduction in traffic...
Suppose that you know that Y, the number of cars passing in front of your house/apartment/dorm...
Suppose that you know that Y, the number of cars passing in front of your house/apartment/dorm room every weekday is a Poisson Random Variable. If the average number of cars per week day is 25, use Chebychev's Inequality to *bound* the probability that Y is at most 32 and more than 18. Simplify your answer
McMahon and Associates, an engineering firm, counted 300 cars passing through an intersection. The observations showed...
McMahon and Associates, an engineering firm, counted 300 cars passing through an intersection. The observations showed that 175 of the cars were traveling in the northbound/southbound lanes and 55 of those turned left at the intersection. The remaining 125 cars were traveling in the eastbound/westbound lanes and 30 of those turned left at the intersection. Use the count data to estimate the probability that a randomly chosen car arriving at the intersection is traveling in the northbound/southbound lanes or is...
Assume that Stafford Township decided to construct a bridge in 2018 that is expected to cost...
Assume that Stafford Township decided to construct a bridge in 2018 that is expected to cost $3,000,000. The bridge construction and related costs are to be financed as follows; Federal Grant                                   $1,200,000 Bond Issue Proceeds                        1,500,000 Transfer from the General Fund      300,000                                                               $3,000,000 The Federal Grant is for 40% of the qualifying project expenditures with a maximum grant limit of $1,200,000. It is an expenditure driven grant. Any excess unearned grant cash received will be refunded to the federal...
In spite of the passing equal pay laws at federal and state levels. Why do you...
In spite of the passing equal pay laws at federal and state levels. Why do you think inequality in pay continues to exist between men and women in the workplace?
(8 marks) Suppose that cars are an external economies of scale good. Imagine that the US...
Suppose that cars are an external economies of scale good. Imagine that the US has an initial (head start) advantage in car production. Mexico has not produced any cars, but is considering entering the car industry. Despite the US’s initial advantage in car production, Mexico is able to enter car production and eventually becomes the world’s only producer of cars. Draw a diagram with a forward falling supply curve for each country (and any other curves you may need) that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT