| naemahabdullah85 (6) | |
|
Question: A parking garage charges RM 0.50 per minute fee. Write a program that prompts user to input the number of hours and minutes parked. The program will then calculate and display the total minutes parked and the charges to be paid by customer based on the basic fee given. If the charges is greater than RM80.00, discount 10% is given to the customer. This is my coding, please help me to solve this prob.TQ guys. #include <iostream> #include <iomanip> #include <math.h> using namespace std; double calculateCharge(double a, double b); int main() double num=0; double num1=0; double total=0; cout<<"\t\t********************************************************"<<endl; cout<<"\t\t\t Welcome to parking garage system"<<endl; cout<<"\t\t********************************************************"<<endl<<endl<<endl; cout<<"\t\tPlease enter first customer's hours parked:"; cin>>num; cout<<"\t\tPlease enter first customer's minutes parked:"; cin>>num1; cout<<endl<<endl; cout<<"\t*****************************************************************"<<endl<<endl<<endl; cout<<setw(5) << "Car" << setw(12) << "Hours" <<setw(12) "Minutes" << setw(16) << "Charge" << endl; cout << setw(5) << num << setw(14) << num1 <<setw(16) << fixed << setprecision(2) << calculateCharge (num, num1) << endl; total = ( calculateCharge (num, num1) ); cout<<setw(5) << "TOTAL" << setw(14) << num << setw(16) << fixed << setprecision(2) << total << endl; system("pause"); return 0; }//end main double calculateCharge(double x, double y) { double charge; if ( (x <= 2) && (y >= 40) ) charge = ( (x * 30) + (y * 0.5) ); else if ( (x > 2) && (y > 40) ) charge = ((x * 30) + (y * 0.5) ); return charge; } | |
|
|
|
| Darkmaster (311) | |
| your main has no opening bracket "{" | |
|
|
|
| naemahabdullah85 (6) | |
| oh ok thanks..how about the full coding.. i can't run this prog by visual basic c++ 2008 | |
|
|
|
| Darkmaster (311) | |
| I will not write the whole code for you. | |
|
|
|
| naemahabdullah85 (6) | |
| oh ok.. | |
|
|
|
| EssGeEich (681) | |
| Can you edit your main post and add the code tags? You just need to select all the code and while it's selected press the <> button on the right (It should be the topleft button) | |
|
|
|
| naemahabdullah85 (6) | |
| ok i'll do it | |
|
|
|
| naemahabdullah85 (6) | |||
| |||
|
Last edited on
|
|||
| naemahabdullah85 (6) | |||
x = hours y = minutes | |||
|
|
|||