Answer to Question #280101 in Java | JSP | JSF for Jay

Question #280101

Procedure:


1. Create a folder named LastName_FirstName in your local drive. (ex. Reyes_Mark)


2. Using NetBeans, create a Java project named MovieTime. Set the project location to your own folder.


3. Import Scanner, Queue, and LinkedList from the java.util package.


4.Create two (2) Queue objects named movies and snacks.


5. Set Weekday as the parent of Monday. Import Scanner from java.util and LocalTime from java.time. For showAlarm(), add these two (2) statements:

          LocalTime alarm = LocalTime.parse(time);

          LocalTime now = LocalTime.now();

          Explanation: parse() converts String to time, while now() obtains the current time.


7. The output shall ask the user to enter the time for the alarm. If the time entered is past the current time, then display "Alarm is set for tomorrow!"; otherwise, display "I'll wake you up later!".


1
Expert's answer
2021-12-15T16:23:13-0500
public class Weekday {
}


public class Monday extends Weekday{
}


import java.time.LocalTime;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class MovieTime {
    public static void showAlarm(String time) {
        LocalTime alarm = LocalTime.parse(time);
        LocalTime now = LocalTime.now();
        if (alarm.compareTo(now) < 0) {
            System.out.println("Alarm is set for tomorrow!");
        } else {
            System.out.println("I'll wake you up later!");
        }
    }

    public static void main(String[] args) {
        Queue<String> movies = new LinkedList<>();
        Queue<String> snacks = new LinkedList<>();
        Scanner in = new Scanner(System.in);
        System.out.println("Enter the time for the alarm");
        String time = in.nextLine();
        showAlarm(time);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog