Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Time First 30 minutes 31 to 60 minutes Each additional 30 minutes 24-hour maximum Pricing FREE $2.00 $1.00 $24.00 Within your Lab7 folder, create a

image text in transcribed

Time First 30 minutes 31 to 60 minutes Each additional 30 minutes 24-hour maximum Pricing FREE $2.00 $1.00 $24.00 Within your Lab7 folder, create a new file named AirportParking.java. Write a method public static int parkingCharge(int minutes) that takes a parameter for the number of minutes parked and returns the appropriate short-term parking charge, in dollars. Assume that the airport will always round UP to the next half-hour - for example, parking exactly 60 minutes would cost $2, but 61 minutes would make it $3. After all, they want to make as much money as possible! If the method is called with a zero or negative argument, make it return zero. If the method is called with an argument exceeding 24 hours, the 24-hour maximum charge should be applied to each complete day, and any partial day should be charged according to the schedule in the table. For example, parking for 1471 minutes would result in a charge of $26. The first 1440 minutes (24 hours) costs $24, the next 30 minutes is free, and the next 1 minute costs $2. Hint: Start by determining three things -1) how long it takes to reach the 24-hour maximum charge (it is NOT 24 hours), 2) how many full days are contained in the argument, and 3) how many 30-minute increments are contained in the partial day that's left over (4 pts) Within the same AirportParking.java file, write a main method that repeatedly asks the user to enter the number of minutes parked, until entering a negative sentinel value to exit. Each time the user enters a number of minutes parked, your main method should call the previously written parkingCharge method and display the value returned 2. Your main method is the only one that should create a Scanner object and read user input. The parkingCharge method gets this information from its minutes argument. Here's an example of what your program might look like when running. The underlined portions indicate user input. Eater number of minutes parked (integers only, any negative value to exit): 8 arking chargef sonutes parked (integers only, any negative value to exit): 30 Parking charge: $0

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

What information should be contained in a change picture?

Answered: 1 week ago