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 - USD4/Hour
Hours 4 to 8 - USD3/Hour
Hours 9 onwards - USD2/Hour
I ALSO NEED TO CONSIDER TO:
1. Parking for 120 minutes is considered 2 hours and therefore would cost USD 8 (2 hour x USD 4) -- DONE
2. Parking for 121 minutes is considered 3 hours and therefore would cost USD 12 (3 hour x USD 4) -- DONE.
This is i am lack ..
3. Parking for 190 minutes is considered 4 hours and therefore would cost USD15 (3 hours x USD 4 + 1 hour x USD 3)
4. Parking for 490 minutes is considered 9 hours and therefore would cost USD 29 (3 hours x USD4 + 5 hours x USD 3 + 1 hour x USD 2)
SO ,, THIS IS WHAT I AM TRYING TO DO,,BUT FAILED..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
>
1. #include <iostream>
2.
3. using namespace std;
4.
5. int main()
6. {
7. float minute, cost, hours1= 4, hours2= 3, hours3= 2;
8.
9. cout<<"Parking fees :"<<endl;
10. cout<<"***************************"<<endl;
11. cout<<"First 3 hours - USD4/Hour "<<endl;
12. cout<<"Hours 4 to 8 - USD3/Hour "<<endl;
13. cout<<"Hours 9 onwards - USD2/Hour "<<endl;
14.
15. cout<<"************************************************"<<endl;
16. cout << "Please insert your parking period (in minute):"<<endl;
17. cin >> minute;
18.
19. // process from minutes to hours
20. float hour = minute / 60;
21.
22. if(hour <= 2){
23. cost = hour * hours1;
24. }
25.
26. else if(hour >= 3 && hour <=4){
27. cost = hour * hours1;
28. }
29.
30. ///CALCULATION OF
31. // Parking for 190 minutes is considered 4 hours and therefore would cost
32. // USD 15 (3 hours * USD 4 + 1 hour * USD 3)
33. else if(hour > 4 && hour <= 8){
34. cost = (3 * hours1) + (1 * hours2 );
35. }
36. //CALCULATION OF
37. // Parking for 490 minutes is considered 9 hours and therefore would cost
38. // USD 29 (3 hours * USD 4 + 5 hours * USD 3 + 1 hour * USD 2)
39. else if( hour > 8){
40. cost = (3 * hours1) + ( 5 * hours2 ) + ( 1 * hours3);
41. }
42.
43. cout << " Your total cost for parking is USD" << cost << endl;
44.
45. return 0;
46. }
|
pls guide me as simple as you can,, i am beginner.. :(