Question

In: Computer Science

Build a program that calculates the parking fare for the customer who parks their cars in...

Build a program that calculates the parking fare for the customer who parks their cars in a public parking lot given the following: i. A character showing the type of vehicle: C for car, B for bus, T for truck ii. An integer between 0 and 24 showing the hour the vehicle entered the lot iii. An integer between 0 and 60 showing the minute the vehicle entered the lot iv. An integer between 0 and 24 showing the hour the vehicle left the lot v. An integer between 0 and 60 showing the minute the vehicle left the lot For encouraging people to park for a short period of time, the management uses two different rates for each type of vehicle as shown below: Vehicle First Rate Second Rate CAR RM 1.00/hr first 3 hr RM 2.00 after first 3 hr TRUCK RM 1.50/hr first 3 hr RM 2.50 after first 3 hr BUS RM 2.00/hr first 3 hr RM 3.00 after first 3 hr No vehicle is allowed to stay in the parking lot later than midnight. If the customer is detected stay parking lot overnight, the customer is required to pay the penalty fee RM 150.00 per day plus the parking fare.

Solutions

Expert Solution

Code:

#include <iostream>

using namespace std;

int main()
{
char type;
int enterHour,enterMinute,leftHour,leftMinute,enterTime,leftTime,finalTime,penalty=0,finalHours;
float fare;
cout<<"Enter vehicle type: ";
cin>>type;
cout<<"Enter an integer between 0 and 24 showing the hour the vehicle entered the lot: ";
cin>>enterHour;
cout<<"Enter an integer between 0 and 60 showing the minute the vehicle entered the lot: ";
cin>>enterMinute;
cout<<"Enter an integer between 0 and 24 showing the hour the vehicle left the lot: ";
cin>>leftHour;
cout<<"Enter an integer between 0 and 60 showing the minute the vehicle left the lot: ";
cin>>leftMinute;
enterTime=enterHour*60+enterMinute;
leftTime=leftHour*60+leftMinute;
if(leftTime<enterTime)
{
finalTime=24*60-enterTime+leftTime;
penalty=150;
}
else
{
finalTime=leftTime-enterTime;
}
if(finalTime%60==0)
{
finalHours=finalTime/60;
}
else
{
finalHours=finalTime/60+1;
}
switch(type)
{
case 'C': if(finalHours<=3)
{
fare=finalHours*1;
}
else
{
fare=3*1+(finalHours-3)*2;
}
break;
case 'T': if(finalHours<=3)
{
fare=finalHours*1;
}
else
{
fare=3*1.5+(finalHours-3)*3;
}
break;
case 'B': if(finalHours<=3)
{
fare=finalHours*1;
}
else
{
fare=3*2+(finalHours-3)*3;
}
break;
default: cout<<"Wrong vehicle type.";
}
cout<<"\nTotal Fare: "<<(fare+penalty);
return 0;
}

Code Screenshot:

Output:

1

2


Related Solutions

. You are working on a bid to build two city parks a year for the...
. You are working on a bid to build two city parks a year for the next three years. This project requires the purchase of $180,000 of equipment that will be depreciated using straight-line depreciation to a zero book value over the 3-year project life. The equipment can be sold at the end of the project for $34,000. You will also need $20,000 in net working capital for the duration of the project. The fixed costs will be $16,000 a...
Last week, 108 cars received parking violations in the green parking lot. Of these, 27 had...
Last week, 108 cars received parking violations in the green parking lot. Of these, 27 had unpaid parking tickets from a previous violation. Assuming that last week was a random sample of all parking violators, find the width of the 90 percent confidence interval for the percentage (correct to four decimal places) of parking violators that have prior unpaid parking tickets.
F- You are working on a bid to build two city parks a year for the...
F- You are working on a bid to build two city parks a year for the next three years. This project requires the purchase of $249,000 of equipment that will be depreciated using straight-line depreciation to a zero book value over the three-year project life. Ignore bonus depreciation. The equipment can be sold at the end of the project for $115,000. You will also need $18,000 in net working capital for the duration of the project. The fixed costs will...
You are working on a bid to build two city parks a year for the next...
You are working on a bid to build two city parks a year for the next three years. This project requires the purchase of $185,000 of equipment that will be depreciated using straight-line depreciation to a zero book value over the 3-year project life. The equipment can be sold at the end of the project for $34,000. You will also need $20,000 in net working capital for the duration of the project. The fixed costs will be $18,000 a year...
Cars arrive at a parking lot at a rate of 20 per hour. Assume that a...
Cars arrive at a parking lot at a rate of 20 per hour. Assume that a Poisson process model is appropriate. Answer the following questions. No derivations are needed but justification of your answers are necessary. What assumptions are necessary to model the arrival of cars as a Poisson process? What is the expected number of cars that arrive between 10:00 a.m and 11:45 a. m? Suppose you walk into the parking lot at 10:15 a.m.; how long, on average,...
QUESTION 1- If a customer slips and falls on the ice in a store’s parking lot,...
QUESTION 1- If a customer slips and falls on the ice in a store’s parking lot, the store may be liable for the tort of: negligence nuisance aggravated assault trespass assault question 2-   Which of the following might prove that a contract was freely entered into by the parties? evidence there has only been presumed pressure but not actual pressure evidence that the terms of the contracts are fair evidence the weaker party received independent legal advice evidence the contract...
Dowell Manufacturing contracts to produce bumper cars for Five Flags Parks. Under the terms of the...
Dowell Manufacturing contracts to produce bumper cars for Five Flags Parks. Under the terms of the contract, Five Flags will pay Dowell a total of $60,000 when bumper cars are delivered six months later, and Five Flags can cancel the contract but must pay Dowell for work completed. Dowell believes that, if Five Flags cancelled the contract, Dowell could not sell the bumper cars to another park. As of December 31, 2020, the job is 80% complete. How much revenue...
Recommend suggestions to Ryanair to build customer loyalty.
Recommend suggestions to Ryanair to build customer loyalty.
A construction company has entered into a contract to build a parking complex. It hsa been...
A construction company has entered into a contract to build a parking complex. It hsa been estimated the complex will cost 700,000 and will take three years to construct. The complex will be billed to the purchasing company at 1,200,000. Information is as follows. X1 YEAR. X2 YEAR X3 YEAR cost incurrect to date 350,000 490,000 700,000 estimated cost yet to be incurrect 350,000. 210,000. 0 customer billings to date 300,000. 650,000 1,200,000 collections of billings to date 250,000. 600,000....
1) Here is a program in c++ that calculates a speeding ticket, modify the program to...
1) Here is a program in c++ that calculates a speeding ticket, modify the program to double to cost of the ticket in a construction zone. // This project will calculate a speeding ticket between 0 to 150 mph. // 1. Ask for speed. // 2. Input speed of vehicle // 3. Calculate ticket cost (50$ if over 50mph with an additional 5$ for every mph over). // 4. Display cost of ticket. #include<iostream> using namespace std; int main() {...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT