Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. A parking garage charges a $3.00 minimum fee to park for up to three hours an

ID: 3662521 • Letter: 3

Question

3. A parking garage charges a $3.00 minimum fee to park for up to three hours and an additional $1.50 per hour for each hour or part thereof over three hours. The maximum charge for any given 24-hour period is $15.00. Assume that no car parks for longer than 24 hours at a time. Write a program that will calculate and print the parking charges for each of three customers who parked their cars in this garage yesterday. You should enter the hours parked for each customer. Your C program should print the results in a neat tabular format, and should calculate and print the total of yesterday’s receipts. Your outputs should appear in the following format:

Car Hours Charge

1 2.5 3.00

2 8.0 10.50

3 12.5 15.00

total 23.0 28.50

(Please be clear in steps, as I'm trying to learn this program)

Explanation / Answer

#include < iostream>

#include < iomanip>

using namespace std;

double calculateCharges( double );

int main()

{

   double first,second, third; //reading three numbers

   cout<<"Enter hours of three customers";

   cin>>first>>second>>third;

   cout<<"Car Hours Charge ";

cout<<"1 "<<fixed<<setprecision(1)<<first<<setprecision(2)<<" "<<calculateCharges(first)<<endl;

cout<<"2 "<<fixed<<setprecision(1)<<second<<setprecision(2)<<" "<<calculateCharges(second)<<endl;

cout<<"3 "<<fixed<<setprecision(1)<<third<<setprecision(2)<<" "<<calculateCharges(third)<<endl;

cout<<"TOTAL "<<fixed<<setprecision(1)<<first+second+third<<fixed<<setprecision(2)<<" "

<<calculateCharges(first)+calculateCharges(second)+calculateCharges(third)<<endl;

system("PAUSE");

return 0;

}

double calculateCharges(double hours)

{

if(hours < 3)

return 3.00;

else

{

if(hours < 24)

return 3.00+(hours - 3)*1.50;

else

return 15.00;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote