Question: 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.For this Java code has already been started. I have attached the

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 day

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!