Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Toll Bridge
Write a program that calculates and returns the toll on the bridge on weekends and holidays with a Good To Go Pass. The program takes three values: hour, minute and ampm and prints out the toll price. Start coding with TollBridgejava 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 : am
$
am to : am
$
am to : am
$
am to : pm
$
pm to : pm
$
pm to : pm
$
pm to : pm
$
Sample run #:
Hours
Minutes
am or pm lower case only am
Timestamp: : am
Charge: $
Input validation
Hours value must be in range 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 #:
Hours
ERROR: Hours value is out of range! Quitting...
Minutes value must be in range 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 #:
Hours
Minutes
ERROR: Minutes value is out of range! Quitting...
am or pm must be correctly spelled in lower case letters. If ampm 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 #:
Hours
Minutes
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
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