Answer to Question #110886 in C++ for Scelo

Question #110886
A parking garage charges a R12.00 minimum fee to park for up to three hours. The garage charges an additional R0.90 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is R20.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 3 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 neat 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. Your outputs should appear in the following format
1
Expert's answer
2020-04-22T08:54:35-0400
#include <iostream>




using namespace std;




float calculateCharges(float customer_time);




int main()

{

  int number = 3;

  float customer_fees[number];

  float customer_times[number];

  int i;

  for(i = 0; i < number; i++)

  {

    cout << "Enter the time of parking of " << i+1 << " customer: ";

    cin >> customer_times[i];

    customer_fees[i] = calculateCharges(customer_times[i]);

  }

  for(i = 0; i < number; i++)

    cout << "Customer's " << i+1 << " fee for " << customer_times[i] << " = " << customer_fees[i] << endl;

  return 0;

}




float calculateCharges(float customer_time)

{

  float amount = 12 + (0.9 * ((int)customer_time - 2));

  if(amount > 20)

    return 20;

  else return amount;

}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
14.04.21, 14:36

Dear Buhlebendalo Hlwempu, Questions in this section are answered for free. We can't fulfill them all and there is no guarantee of answering certain question but we are doing our best. And if answer is published it means it was attentively checked by experts. You can try it yourself by publishing your question. Although if you have serious assignment that requires large amount of work and hence cannot be done for free you can submit it as assignment and our experts will surely assist you.

Buhlebendalo Hlwempu
14.04.21, 12:35

This code is not running on my laptop,it is saying that customer_time is not declared

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS