A parking garage has 5 customers daily. The garage charges a \$5.00 minimum fee to park up to two hours. The garage charges an additional \$1.00 per hour for each hour (or part of an hour) over two hours. The maximum charge for any given day is \$12.00. All cars are gone by midnight. Write a program to calculate and print a summary of the charges for a day. For input the program will read the hours of usage for each of the 5 cars. The program will print the results in the form of a table in a neat format, as shown below.

Enter the hours parked for car 1: 1.5
Enter the hours parked for car 2: 4.1
Enter the hours parked for car 3: 12.0
Enter the hours parked for car 4: 9.3
Enter the hours parked for car 5: 0.5

Total Hours 27.4
Total Charge \$42.00

Use one decimal place for the hours parked, and 2 for the total charge

This is not a code writing service. If you have code and it is giving you a problem then post the code and what the problem is. No one here is going to do your work for you.

What Nathan is saying (nicer than I would) is that we don't do your homework for you!

## All 6 Replies

This is not a code writing service. If you have code and it is giving you a problem then post the code and what the problem is. No one here is going to do your work for you.

What Nathan is saying (nicer than I would) is that we don't do your homework for you!

i wasn't asking for the code, i just wanted the logic behind the question thank you very much.

i just wanted the logic behind the question thank you very much.

The input will be five numbers. For each number, calculate a new number according to these rules:

If the entered number is less than two, the new number is SOMETHING.
If the entered number is more than two, round it up, and the new number is the (rounded-up number - minus two)+5.
If the entered number is over eight, the new number is SOMETHING.

Add up all five of the new numbers.

That was very simple. It required thinking, and possibly some experimenting on paper. Here's the important bit: THIS is programming. THINKING. Breaking a problem down into small steps and solving it in a logical way that can be programmed. THIS is programming.

I left some of it for you to do. You need to work out what those SOMETHINGs are. I did the hardest one for you. If you can't work it out, write it on paper. Experiment with different inputs until you work it out. THIS is programming. All the junk with the language is just learning your tools.

Dealing with the logic is 99% of the work in programming. Moschops is being very nice to you! Show your work, and logic. Start with pseudo-code.

Thank you very much. That definitely helped :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.