Question

In: Computer Science

A parking garage charges R7.50 minimum fee to park for up to three and half hours....

A parking garage charges R7.50 minimum fee to park for up to three and half
hours. The garage charges an additional R1.50 per hour for each hour or part
thereof in excess of three hours. The maximum charge for any given 24- hour
period is R25.72. Write a program that calculates and prints the parking
charges for each of three customers who parked their cars in this garage at
some time. You should enter the hours parked for each customer. Your
program should print the results in a neat tabular format and should calculate
and print the total of receipts. The program should use the function
calculateCharges to determine the charge for each customer. The payment
amounts should be printed inside the body of main().

Solutions

Expert Solution

SOLUTION -:

C++ Code for the above problem is as given in screenshots below -:

C++ Code -:

In this code, we take charge of the R7.5 minimum fee to park up to three and a half hours.

Output -:

output_1-:

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double calculateCharges (double hours)
{  
   double result;
   // Minimum Charge for upto three and half hours
   if (hours <= 3.50)
       result = 7.50;
   // Maximum Charge for 24 hours
   // Here hours > 15 because
   //when we calculate upto 15 then Charge is less than 25.72
   else if (hours > 15.00)
       result = 25.72;
   else
   // additional R1.50 charge per hour for each hour or part
// thereof in excess of three hours.
       result = 7.50 + ceil((hours - 3)) * 1.50;
   return result;
}

int main()
{
   double totalCharge = 0;
   double totalHours = 0;
   double charge;
   double hoursFirst, hoursSecond, hoursThird;
   cout << "Enter hours parked for all three customers" << endl;
   cin >> hoursFirst >> hoursSecond >> hoursThird;
   cout << left << setw(10) << "Car" << setw(10) << right << "Hours"
               << setw(10) << "Charge" << endl;
   // Output for Customer 1
   charge = calculateCharges(hoursFirst);
   totalCharge += charge;
   totalHours += hoursFirst;
   cout << fixed << left << setw(10) << "Car 1" << setw(10) << right << setprecision(1) << hoursFirst
                   << setw(10) << setprecision(2) << charge << endl;
   // Output for Customer 2
   charge = calculateCharges(hoursSecond);
   totalCharge += charge;
   totalHours += hoursSecond;
   cout << fixed << left << setw(10) << "Car 2" << setw(10) << right << setprecision(1) << hoursSecond
                   << setw(10) << setprecision(2) << charge << endl;
   // Output for Customer 3
   charge = calculateCharges(hoursThird);
   totalCharge += charge;
   totalHours += hoursThird;
   cout << fixed << left << setw(10) << "Car 3" << setw(10) << right << setprecision(1) << hoursThird
                   << setw(10) << setprecision(2) << charge << endl;
   // Output for Total
   cout << left << setw(10) << "TOTAL" << setw(10) << right << setprecision(1) << totalHours
               << setw(10) << setprecision(2) << totalCharge << endl;
}


Related Solutions

Write a Java Program.A parking garage charges a $3.00 minimum fee to park for up to...
Write a Java Program.A parking garage charges a $3.00 minimum fee to park for up to three hours. The garage charges an additional $0.75 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $12.00 per day. Write an application that calculates and displays the parking charges for all customers who parked in the garage yesterday. You should enter the hours parked for each customer. The program should...
Use CPP 1) Parking charge application: A parking garage charges a $20.00 minimum fee to park...
Use CPP 1) Parking charge application: A parking garage charges a $20.00 minimum fee to park for up to 3 hours. The garage charges an additional $5.00 per hour for hour or part thereof in excess of 3 hours. The maximum charge for any given 24-hour period is $50.00. Assume that no car parks for longer than 24 hours at a time. Write a program that calculates and prints the parking charge for each of 3 customers who parked their...
C program and pseudocode for this problem. A parking garage charges a $2.00 minimum fee to...
C program and pseudocode for this problem. A parking garage charges a $2.00 minimum fee to park for up to three hours and additional $0.50 per hour 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...
Loaded-up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.90%. Economy...
Loaded-up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.90%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.10%. Assume the ratio of return on both funds' portfolios (before any fees) is 5% per year. How much will an investment of $100 in each fund grow after 1 year? How much will an investment of $100 in each fund grow after 2 years? loaded-up fund...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.70%. Economy...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.70%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.30%. Assume the rate of return on both funds’ portfolios (before any fees) is 7% per year. a. How much will an investment of $100 in each fund grow to after 1 year? (Do not round intermediate calculations. Round your answers to 2 decimal places.) Loaded-Up Fund...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.75%. Economy...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.75%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.25%. Assume the rate of return on both funds’ portfolios (before any fees) is 6% per year. a. How much will an investment of $100 in each fund grow to after 1 year? (Do not round intermediate calculations. Round your answers to 2 decimal places.) Loaded up...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.80%. Economy...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.80%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.20%. Assume the rate of return on both funds’ portfolios (before any fees) is 10% per year. a. How much will an investment of $100 in each fund grow to after 1 year? (Do not round intermediate calculations. Round your answers to 2 decimal places.) Loaded-Up Fund...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.90%. Economy...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.90%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.10%. Assume the rate of return on both funds’ portfolios (before any fees) is 5% per year. a. How much will an investment of $100 in each fund grow to after 1 year? (Do not round intermediate calculations. Round your answers to 2 decimal places.)   Loaded-Up Fund...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.75%. Economy...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.75%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.25%. Assume the rate of return on both funds’ portfolios (before any fees) is 7% per year. a. How much will an investment of $100 in each fund grow to after 1 year? (Do not round intermediate calculations. Round your answers to 2 decimal places.)   Loaded-Up Fund...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.65%. Economy...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.65%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.35%. Assume the rate of return on both funds’ portfolios (before any fees) is 6% per year. a. How much will an investment of $100 in each fund grow to after 1 year? (Do not round intermediate calculations. Round your answers to 2 decimal places.)   Loaded-Up Fund...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT