Answered step by step
Verified Expert Solution
Question
1 Approved Answer
HW 1 Basics and Control Statements ( 1 0 0 pts . ) : The Safe Keeping Parking Garage determines the price it charges for
HW Basics and Control Statements pts:
The Safe Keeping Parking Garage determines the price it charges for parking based on the
day of the week and the time spent parked. To avoid bleeding its customers dry, the garage
has maximum fees it will charge. Here are the rules the company uses to calculate its prices:
Day of Week
Rate for
Minutes or
Portion Thereof
Maximum
Fee
Charged
Monday Friday
Saturday & Sunday
To help you understand the business process, the garage manager created the following
examples to illustrate some parking situations:
Day of
Week
Vehicle
Arrives
at
Vehicle
Leaves
at
Arrival
Minutes
Depart
Minutes
Duration
in Minutes
Minute
Intervals
Rate
Charge
Based on
Rate
Max
Charge
Actual
Charge
M F
M F
M F
M F
M F
M F
M F
M F
S & S
S & S
Notice that the arrival in minutes is the number of hours in the arrival time multiplied by
plus the number of minutes. For instance, in the first row the Arrival Minutes is calculated
as hours times giving plus minutes resulting in a total of minutes. Likewise,
the Depart Minutes is calculated as hours times giving minutes plus minutes
resulting in total of minutes. How might you use integer division and modulus operations
to separate hours and minutes from an int?
The table above represents time in a hour format using integers. This makes calculating
duration much easier. As anyone who has used a parking garage knows, the number of
minute intervals counts even a minute over as a new interval. For instance, a duration of
minutes produces minute intervals, and a duration of minutes produces intervals.
In the sixth row above, a duration of minutes is minute intervals full intervals
plus minutes of the next one.
Since negative durations cannot exist, display an error message if the user enters an arrival
time that exceeds the departure time.
Develop a set of test plan results that shows that your program produces correct results.
Write a Java program to calculate the ampunt charged for parking in the garage over a
specified interval on any given day. The program must implements the requirements
described above. It will use an object of either the Scanner class or the BufferedReader class
to obtain input.
The program should request information from the user in the following format:
Please enter the day of the week : mon
Please enter the vehicles arrival time :
Please enter its departure time :
The program will use printf with the appropriate format specifiers to display the output
which should look like this:
Day of week: Mon
Parking duration in minutes: rate: $
Amount charged: $
Be sure to use the correct data type for the variables that will store the user input.
Write an efficient algorithm: try to obtain the correct results using the fewest possible
number of steps.
You will also develop a test plan that shows what values you tested and whether the program
correctly calculated the cost of parking.
You will upload your test file and your java file compressed together in a zip or z file.
Be sure to use the assignment naming convention for your compressed file, for instance,
DAngelo HWzip.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started