THIS IS THE QUESTION.

1- The user would enter how many minutes he/she would like to park in the parking lot.

2- The program would output the parking cost.

3 - The rate charge by the parking lot is as follows

First 3 hours - RM4/Hour

Hours 9 onwards - RM2/Hour

I ALSO NEED TO CONSIDER TO:

1. Parking for 120 minutes is considered 2 hours and therefore would cost RM 8 (2 hour x RM 4)

2. Parking for 121 minutes is considered 3 hours and therefore would cost RM 12 (3 hour x RM 4)

3. Parking for 190 minutes is considered 4 hours and therefore would cost RM 15 (3 hours x RM 4 + 1 hour x RM 3)

4. Parking for 490 minutes is considered 9 hours and therefore would cost RM 29 (3 hours x RM 4 + 5 hours x RM 3 + 1 hour x RM 2)

SO ,, THIS IS WHAT I AM TRYING TO DO,,BUT FAILED..

```
#include <iostream>
using namespace std;
int main()
{
float minute, cost, hours1= 4, hours2= 3, hours3= 2;
cout<<"Parking fees :"<<endl;
cout<<"***************************"<<endl;
cout<<"First 3 hours - RM4/Hour "<<endl;
cout<<"Hours 4 to 8 - RM3/Hour "<<endl;
cout<<"Hours 9 onwards - RM2/Hour "<<endl;
cout<<"************************************************"<<endl;
cout << "Please insert your parking period (in minute):"<<endl;
cin >> minute;
// process from hour to minutes
float hour = minute / 60;
if(hour <= 2){
cost = hour * hours1;
}
else if(hour >= 3 && hour <=4){
cost = hour * hours1;
}
///CALCULATION OF
// Parking for 190 minutes is considered 4 hours and therefore would cost
// RM 15 (3 hours * RM 4 + 1 hour * RM 3)
else if(hour > 4 && hour <= 8){
cost = (3 * hours1) + (1 * hours2 );
}
//CALCULATION OF
// Parking for 490 minutes is considered 9 hours and therefore would cost
// RM 29 (3 hours * RM 4 + 5 hours * RM 3 + 1 hour * RM 2)
else if( hour > 8){
cost = (3 * hours1) + ( 5 * hours2 ) + ( 1 * hours3);
}
cout << " Your total cost for parking is RM" << cost << endl;
return 0;
}
```

*Edited 3 Years Ago by deceptikon*: Moved to the C++ forum