Answered step by step
Verified Expert Solution
Link Copied!

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

HW1 Basics and Control Statements (100 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 15
Minutes or
Portion Thereof
Maximum
Fee
Charged
Monday - Friday 1.2515.00
Saturday & Sunday 0.5015.00
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
15
Minute
Intervals
Rate
Charge
Based on
Rate
Max
Charge
Actual
Charge
M - F 745100046560013591.2511.251511.25
M - F 7001200420720300201.25251515
M - F 11301600690960270181.2522.51515
M - F 1305150078590011581.25101510
M - F 142015008609004031.253.75153.75
M - F 75017154701035565381.2547.51515
M - F 17301900105011409061.257.5157.5
M - F 17551905107511457051.256.25156.25
S & S 140019208401160320220.5111511
S & S 9401425580865285190.59.5159.5
Notice that the arrival in minutes is the number of hours in the arrival time multiplied by 60
plus the number of minutes. For instance, in the first row the Arrival Minutes is calculated
as 7 hours times 60 giving 420 plus 45 minutes resulting in a total of 465 minutes. Likewise,
the Depart Minutes is calculated as 10 hours times 60 giving 600 minutes plus 0 minutes
resulting in total of 600 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 24 hour format using integers. This makes calculating
duration much easier. As anyone who has used a parking garage knows, the number of 15
minute intervals counts even a minute over as a new interval. For instance, a duration of 60
minutes produces 415 minute intervals, and a duration of 61 minutes produces 5 intervals.
In the sixth row above, a duration of 565 minutes is 3815 minute intervals 37 full intervals
plus 10 minutes of the next one.
1
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 : 745
Please enter its departure time : 1000
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: 135, rate: $1.25
Amount charged: $11.25
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 7z file.
Be sure to use the assignment naming convention for your compressed file, for instance,
DAngelo HW1.zip.

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

More Books

Students also viewed these Databases questions

Question

Give the reliability function of the structure of Exercise 8.

Answered: 1 week ago

Question

What is quality of work life ?

Answered: 1 week ago

Question

What is meant by Career Planning and development ?

Answered: 1 week ago

Question

What are Fringe Benefits ? List out some.

Answered: 1 week ago