hii everyone, im trying to figure out how to do this assignment but i dont know to continue. im not sure how to convert hours to min, the formula to find parking fee and use if and else to solve this problem.thank you very much
here is the assignment.
Parking:
Cars;
first 2 hours; 3.00
hours over 2: 2.50/hr
Senior Citizens: 0.50/hr
Design a program will
Determine the total number of minutes park
Determine the cost to park. any portion of an hour should be counted as a full hour.Ex: if time parked is 70 mins, charge for 2 hours.
HERE IS THE SAMPLE OF THE OUTPUT OF THE ASSIGNMENT:
enter parking category (C=car, S=senior)
c
time of entry? (hh:mm)
5:30
time of exit? (hh:mm)
12:00
minures parked: 390
parking fee: $15.00
THIS IS WHAT I'VE DONE
char parking;
int entrytime, exittime, mins, hours, rem, x;
float total;
cout << "enter parking category (C or S)" <<endl;
cin >> parking
if (parking == 'S' || parking == 's')
{
cout << "time of entry? (hh:mm)" <<endl;
cin >> entrytime
cout << "time of exit? (hh:mm)" <<endl;
x = exittime - entrytime
hours = mins/60
mins = min%60
cout << "time of entry? (hh:mm)" <<endl;
cin >> entrytime
cout << "time of exit? (hh:mm)" <<endl;
Firstly, you've forgot to get the input from the user for the time of exit.
Secondly, as entrytime and exittime are both of type int this won't work, as ':' is not an enter. This would most likely mess up your program beyond belief. You're going to have to take the input as a string (C-string / string object) and parse it.
promt for start and finish times as (hr,min)
then you get:
cin>>hr1>>min1;
st=hr1+min1/60; //start time
ditto for ft=hr2+min2.
duration=ft-st//etc
But this assumes that that all the action occurs within a standard 24 hr day! else time requires dates for manipulation as well.