Oct 27, 2012 at 10:23pm UTC
here's a sample problem. can anyone pls help?
A program that will accept the following:
1. Plate Number of a car.
2. Parking Level
3. Number of Hours Parked
Compute and display the Parking Fee based on the following:
1. First 2 hours = 30 pesos
2. Succeeding Hours = 20 pesos / hour
3. Parking Level A -> No Discount
4. Parking Level B -> 5% Discount
5. Parking Level C -> 10% Discount
6. Other parking Level -> "Invalid Input"
Oct 28, 2012 at 12:10am UTC
We don't help you do your homework, why don't you post what you have done so far and we'll help you from there.
Oct 28, 2012 at 1:51am UTC
Do you wish to know how to use if, else if, and else statements? If so, if statements test if a variable matches a certain value.
cout<<"Enter a number.\n";
cout<<"Your number is 1.\n";
else if (num="2")
cout<<"Your number is 2.\n";
cout<<"Your number is another number.\n";
I hope I helped! Also, remember to never put a semicolon after the parentheses of an if or else if statement!
Oct 31, 2012 at 10:14pm UTC
2 3 4
cout<< "invalid input";
Your code is not in the braces here. You dont need the braces if the IF has only 1 statement, but its a good idea to use braces anyways incase you add onto the program later.
It is really hard to determine what braces match to what braces. So I might be wrong but it looks like you dont have any opening braces for your if statements.
So be consistent with your braces. What I mean is this, here are 2 examples where you place your braces in different positions.
2 3 4 5 6 7 8 9 else if (floorLevel == 'b')
cout<< "Floor Level B Discounted Price: "<<totalhours-(totalhours*.05)<< "php"<<endl;
else if (floorLevel == 'c')
cout<< "Floor Level C Discounted Price: "<<totalhours-(totalhours*.10)<< "php"<<endl;
What ever style you use is up to you just be consistent with whatever style you use.
Just a few pointers
Last edited on
Oct 31, 2012 at 10:18pm UTC