Parking Program

I have a program where a parking garage charges 6 dollars for 3 hours. for extra hours, they charge an extra 2.50. for a 24 hour period they charge 35 dollars. i have my code and it runs but still gets the calculations kind of wrong.
What is the right formula to calculate the extra cost if it goes over 3 hours?
What is the right formula to get the 24 hours to set to 35 dollars?
what is the right formula to calculate if it goes over 25 hours?
How can i set a for loop?

[#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main ()
{
int hOurs = 0;
float chrGe, exchRge, pchgrGe;
double total, chArge = 6.00, extrachArge = 2.50, periodchA = 35.00;


cout << "Please enter number of hours parked: ";
cin >> hOurs;



if(hOurs <= 3)
{
total = chArge;
}
else if( hOurs >= 3)
{
total = (chArge - hOurs + 3)* extrachArge;
}
else if(hOurs >= 24)
{
total = periodchA;
}


cout << "Your total charge is: $" << total << endl;


system("pause");
return 0;

}
]
Put the code you need help with here.
[/code]
Your problem probably lie int his line:
else if (hOurs >= 3)
You haven't given it an upper bound. So it evaluates at 3, and more importantly 24 and up.
Topic archived. No new replies allowed.