Please, please please someone help me. This might sound a little pathetic but I cannot figure this out for the life of me, it compiles just fine but i get the complete wrong output. Here is all the code I have.
The problem:
Write an application a that calculate the parking fee for a car for one day. The parking garage changes a $2.00 minimum fee for up to 3 hours. The garage charges an additional $0.50 per hour for each hour or partial hour in excess of three hours. The maximum charge is $10.00 for a 24 hour period. Assume that no car parks for longer than 24 hours at a time. Your application should ask for a total time parked in a decimal format and the state the total parking charge.
I try to enter 4.5 hours and get a total of 2.5$ when the answer should be 3$
The code:
#include<iostream>
using namespace std;
int main()
{
float floatHour = 0;
float floatFees = 0;
int carryOver = 0, intHour = 0;
cout<<"Enter number of hours parked: ";
cin>>floatHour;
if (floatHour <= 3)
floatFees = floatFees + 2.00;
if (floatHour > 3)
carryOver = (floatHour * 100);
carryOver = carryOver % 100;
intHour = ((floatHour * 100) / 100);
if (carryOver == 0)
floatFees = (intHour * .50) + floatFees;
else if (carryOver > 0)
floatFees = (intHour * .50) + floatFees + .50;
if (floatFees >= 10)
floatFees = 10;
cout<<"Your total is: $"<<floatFees<<endl;
system("PAUSE");
return 0;
}