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

5.9 ( Parking Charges) A parking garage charges a $ 2.00 minimum fee to park for

ID: 3733679 • Letter: 5

Question

5.9 ( Parking Charges) A parking garage charges a $ 2.00 minimum fee to park for up to three hours and an additional $ 0.50 per hour for each hour or part thereof over three hours. The maximum charge for any given 24- hour period is $ 10.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 program should print the results in a tabular format, and should calculate and print the total of yesterday's receipts. The program should use the function calculateCharges to determine the charge for each customer. (calculateCharges will be made by you.) Please keep the hours data in an array. car hours charge 1 1.5 2.00 2 4 2.50 3 24 10.00 TOTAL 29.5 14.50 In this program -- you will have loops, arrays and functions. For extra credit, put your function prototypes in a header file that you made.

Explanation / Answer

#include <bits/stdc++.h>

using namespace std;

float calculateCharges(int hours)

{

if(hours <= 3)

return 2.00;

else

{

float ans;

ans = (hours - 3)*0.50;

if(ans >= 10.00)

return 10.00;

else

return ans;

}

}

int main()

{

int a,b,c;

cout<<"Enter the Number of hours three cars stayed"<<endl;

cin>>a>>b>>c;

float p,q,r;

p = calculateCharges(a);

q = calculateCharges(b);

r = calculateCharges(c);

cout<<"========================"<<endl;

cout<<"sl.no || Hours || Cost"<<endl;

cout<<"1 ||"<<a<<" ||"<<p<<" ||"<<endl;

cout<<"2 ||"<<b<<" ||"<<q<<" ||"<<endl;

cout<<"3 ||"<<c<<" ||"<<r<<" ||"<<endl;

cout<<"TOTAL ||"<<a+b+c<<" ||"<<p+q+r<<" ||"<<endl;

cout<<"========================="<<endl;

}

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