Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For this Java code has already been started. I have attached the code below. public class Alarm { public static void main(String[] args) { //
For this Java code has already been started. I have attached the code below.
public class Alarm {
public static void main(String[] args) { // Do not edit the main program Scanner keyboard = new Scanner(System.in); int day = keyboard.nextInt(); boolean snooze = keyboard.nextBoolean(); System.out.print (alarm(day, snooze)); }
public static String alarm(int day, boolean snooze) { // Code goes here. }
}
Write a method that simulates the logic of an alarm clock. The method has two inputs: an integer and a boolean. The integer represents a day of the week with O being Sunday, 1 Monday, 2 Tuesday, ..., and 6 Saturday. The boolean indicates whether the snooze button has been pressed. The method returns a String that gives the time the alarm will ring. On weekdays, the alarm rings at "8:00". On weekends, the alarm rings at "10:30". If the snooze button has been pressed, the alarm is delayed 5 minutes on weekdays and 15 minutes of weekends. Finally, the method should check for invalid day inputs. If an invalid integer is given, the method should return "invalid dayStep 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