Question: 5 2 0 Toll Bridge Write a program that calculates and returns the toll on the 5 2 0 bridge on weekends and holidays with

520 Toll Bridge
Write a program that calculates and returns the toll on the 520 bridge on weekends and holidays with a Good To Go! Pass. The program takes three values: hour, minute and am/pm and prints out the toll price. Start coding with TollBridge520.java provided. Keep input and output statements without change, add logic that calculated the toll based on the following table:
Weekends and Holidays**
Good To Go! Pass Toll
Midnight to 4:59 am
$1.25
5 am to 7:59 am
$1.40
8 am to 10:59 am
$2.05
11 am to 5:59 pm
$2.65
6 pm to 8:59 pm
$2.05
9 pm to 10:59 pm
$1.40
11 pm to 11:59 pm
$1.25
Sample run #1:
Hours (1-12)=>12
Minutes (0-59)=>15
am or pm (lower case only)=> am
Timestamp: 12:15 am
Charge: $1.25
Input validation
1) Hours value must be in range [1,12]. If the hours value is invalid, an error message containing word ERROR in all caps must appear and the program must quit right away. See sample program run below:
Sample run #2:
Hours (1-12)=>0
ERROR: Hours value is out of [1,12] range! Quitting...
2) Minutes value must be in range [0,59]. If the minutes value is invalid, an error message containing word ERROR in all caps must appear and the program must quit right away. See sample program run below:
Sample run #3:
Hours (1-12)=>1
Minutes (0-59)=>60
ERROR: Minutes value is out of [0,59] range! Quitting...
3)am or pm must be correctly spelled in lower case letters. If am/pm string is invalid, an error message containing word ERROR in all caps must appear and the program must quit right away. See sample program run below:
Sample run #4:
Hours (1-12)=>1
Minutes (0-59)=>55
am or pm (lower case only)=> Am
ERROR: Invalid string. Must be either "am" or "pm". Quitting...
The following chart may be helpful if you are more used to military time and not very confident when converting it into the standard one.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!