I am having a problem getting the execution screen to stay in order for me to view the program. Can someone tell me what is wrong with my program please?
//
/*
A parking garage charges a $2.00 miniumum fee to pack for up to three hours.
The garage charges an additional $0.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.00.
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 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 neat tubular format and should calculate
and print the total of yesterday’s receipts. The program should A parking garage charges
a $2.00 miniumum fee to pack for up to three hours. The garage charges an additional
$0.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.00. 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
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 neat tubular 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.
*/
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
#include <iomanip>
using std::setprecision;
const int CARS = 3;//number of cars parked yesterday
//function used to calculate parking charges
double calculateCharges(double hours)
{
double charge;
// charge minnimum rate of 2 dollars for 3 hours
if (hours<=3)
{
charge=2;
}
// hours > 3
else
{
charge=2; // charge base rate of 2 dollars
hours-=3; // check how long over 3 hours the car was parked
while(hours>0)
{
charge+=.5; // charge 50 cents for extra hours
hours--; // hour or part of was charged
}
}
if (charge>10) // flat rate of 10 dollars is charged
charge=10;
return charge;
}
int main()
{
double hours[CARS]; // store hours parked by the different cars
double thours=0, tcharge=0, charge; // stores daily totals and total for a car
int i;
cout << "Parking Garage" << endl;
// get hours parked
for(i=0; i<CARS;i++)
{
cout << "How long was car " <<(i+1)<<" parked? ";
cin >> hours;
}
//print header
cout << endl;
cout << "Car\tHours\tCharge" << endl;
// for each car
for(i=0;i<CARS;i++)
{
// get amount owed
charge = calculateCharges (hours);
// display charges
// car
cout << (i+1);
// hours
cout << setprecision ( 1 );
cout << hours;
// charges
cout << setprecision ( 2 );
cout << charge << endl;
// add to daily totals
thours+=hours;
tcharge+=charge;
}
// print totals
cout << "Total" << thours << tcharge << endl;
return 0;
}