Hey guys need some help!

Hey guys I'm in terrible need of some basic help, I was given this assignment and i can't quite figure it out, most of you will find this extremely basic however..;

A parking garage charges $6 flat rate to park for up to three hours. The garage charges an

additional $2.50 per hour for each hour after the three hours. The maximum charge for any given

24-hour period is $35. Assume that no car parks for longer than 24 hours at a time.

Write a program for a parking attendant that calculates and displays the parking charges for each

customer who parked a car in this garage. Make sure that the value entered is positive. Allow the

parking attendant to compute the charges for as many customers as desired without exiting the

program. The attendant will decide when to exit the program.

Make sure the program displays the charges for every car entered. Once the attendant decides

to stop, the program also displays the number of cars entered, the total dollar amount for all the

cars, and the average charge per car.

This is what I have so far but I can't figure out what i'm doing wrong..

Code:

#include <math.h>
#include<iostream>
#include<iomanip>


using namespace std;

int main()

{
double hours;
int i;


cout << setw(10) << "Enter hours: ";
cin >> hours;


cout << "CAR" << setw(10) << "Hours" << setw(10) << "Price\n";
cout << setw(25);




for (i = 1; i <= 3; i++)
{
(hours, i);
cout << setw(25);
cin >> hours;

}

cout << endl;

}



double x;
double charge;



cout << i << setw(10) << hours << setw(10);
if (hours<3 && hours>0)
{
cout << "6.00";

}

else
if (hours == 24)
{
cout << "35.00";
}
else
{
x = (hours)-3;
charge = x*0.5;
cout << charge + 2.50;
}

system("pause");
return (0);



If anybody could lend me a hand I'd be eternally grateful, i'd even consider paying you lol. Thanks guys!
You should make a variable for the final cost. For example


double cost;

if(hours<3 && hours>0)
cost=6;
if(hours>3)
cost=6+2.5*(hours-3);
if(cost>35)
cost=35;


This will calculate the cost for one car. Use a loop to do this for as many cars as the operator wants and make a variable for how many cars he enters and the total for all the cars so you can print those out at the end as well as the average. Also put in a statement to deal with if the number of hours entered is negative.
THANK YOU !!!! <3
Topic archived. No new replies allowed.