Answered step by step
Verified Expert Solution
Question
1 Approved Answer
These are the directions, my current code, and the error.public class LabProgram { public static double calcToll ( int hour, boolean isMorning, boolean isWeekend )
These are the directions, my current code, and the error.public class LabProgram
public static double calcTollint hour, boolean isMorning, boolean isWeekend
Weekday toll rates
double beforeamWeekday ;
double fromamToamWeekday ;
double fromamTopmWeekday ;
double frompmTopmWeekday ;
double frompmWeekday ;
Weekend toll rates
double beforeamWeekend ;
double fromamTopmWeekend ;
double frompmWeekend ;
Check if it is a weekend
if isWeekend
if hour
return beforeamWeekend;
else if hour
return fromamTopmWeekend;
else
return frompmWeekend;
else It's a weekday
if hour
return beforeamWeekday;
else if hour
return fromamToamWeekday;
else if hour
return fromamTopmWeekday;
else if hour
return frompmTopmWeekday;
else
return frompmWeekday;
public static void mainString args
Test cases
System.out.printlncalcToll true, false; Should return
System.out.printlncalcToll false, false; Should return
System.out.printlncalcToll false, true; Should return
System.out.printlncalcToll true, true; Should return
System.out.printlncalcToll false, false; Should return
System.out.printlncalcToll false, false; Should return
System.out.printlncalcToll false, true; Should return
System.out.printlncalcToll false, true; Should return
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