Computer Science, asked by dachapallytarun, 5 months ago

A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $10. Assume that no car parks for longer than 24 hours at a time. Write a program that calculates and prints 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.

Answers

Answered by dreamgirl17q
0

Answer:

What is the C++ code for a car parking system?

acknowledge that you have read and understand our , , and our .

-5

#include <iostream>

using namespace std;

int elapsed_time(int entry_time, int exit_time)

{

int total = 0;

total = (exit_time / 100) * 60 + (exit_time % 100) - (entry_time / 100) * 60

+ (entry_time % 100);

return total;

} // returns elapsed time in total minutes

double parking_charge(int total_minutes) {

double total = 0;

double cents = 0;

if(total_mins < 30){

return 0;

}

else if (total_mins <= 120){

cents = (total_mins - 30) * 0.05;

return total = 3 + cents;

}

else{

cents = (total_mins - 120) * 0.10;

return total = 4.5 + 8 + cents;

}

} // returns parking charge

void print_results(total_minutes, double charge)

{

cout << "The charge of parking was: " << parking_charge(total_minutes)

}

int main() {

int entry_time = 0;

int exit_time = 0;

cout << "What was the entry time? (Enter in 24 hour time with no colon) ";

cin >> entry_time;

cout << "What was the exit time? (Enter in 24 hour time with no colon) ";

cin >> exit_time;

cout << print_results(total_minutes, charge);

}

I have updated my code with a working parking charge function. I am now aiming to get the print_results function working correctly and finding out how to get all of this to work together in the main function. Thanks to all for the help so far.

Similar questions