Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java work A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour

Java work

A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer and 24 hours at a time.

Write an application that calculates and displays the parking charges for each customer who parked in the garage yesterday. You should enter the hours parked for each customer. The program should display the charge for all customers and should calculate and display the total charges for the day.

Your application must implement the following methods:

public static double[] obtainData()

The obtainData method will ask the user how many cars parked in the garage yesterday and obtain how many hours each car was parked. The numbers of hours each car was parked will be placed in a double array which is returned by the obtainData method.

public static double calculateCharge(double hours)

The calculateCharge method will calculate the correct charge given the rules stated above for the number of hours passed into the method.

public static double calculateTotal(double[] hours)

The calculateTotal method will calculate the total charges given the rules stated above. This method should leverage the calculateCharge method to perform this task.

Example Application Input/Output: How many cars parked in the garage yesterday?

3

How many hours did car #1 park for?

3.0

How many hours did car #2 park for?

12.0

How many hours did car #3 park for?

4.5

$2.00

$6.50

$2.75

Total: $11.25

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions

Question

What online recruitment methods are available?

Answered: 1 week ago