Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The office hours for Professor X in Spring 2021 are as follows: Monday 3:00pm - 5:00pm Thursday 3:30pm - 5:00pm Friday 3:00pm - 4:30pm
The office hours for Professor X in Spring 2021 are as follows: Monday 3:00pm - 5:00pm Thursday 3:30pm - 5:00pm Friday 3:00pm - 4:30pm Note that all office hours are in the late afternoon. For this lab assignment, you will write a program that will take the day of the week and a time (XX:XXam/pm) as inputs, and will output whether the professor is available during that time on that day. Start Apache NetBeans. Create a new project called YourlastnameLab4 with your last name. Declare a String variable to represent the day of the week. Prompt the user for the day of the week and store it in the variable from step 3. The result should look like this: Enter the day of the week: Monday Declare a String variable to represent the time of day. Prompt the user for the time of day in the format XX:XXam/pm (e.g., 10:45am, 3:30pm), and store it in the variable from step 5. The result should look like this: Enter a time (XX:XXam/pm): 4:15pm Declare two int variables to represent the hour and minute, and a String variable to represent a value of "am" or "pm". Use the String class length, indexOf, and substring methods to process time to extract the hour, minute, and am/pm information. Store the results in the three variables from step 7. You will need to use the Integer.parseInt method to convert a String to an int. int number = Integer.parseInt("42"); // converts "42" to 42 Use if-else statements to display the entered day of the week in the following format: Day of the week: Monday Use the String class equals IgnoreCase method to identify the entered input in different format (e.g. "Mon", "mon", "MON", "Monday", "monday", "MONDAY"). Use the logical OR operator || to build the Boolean expressions. . 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. For each day when the professor does not have office hour (Tuesday, Wednesday, Saturday, Sunday), add an additional statement that displays "Not Available". For days, when the professor has office hours (Monday, Thursday, and Friday), write nested if-else statements within the respective if-else statements described in step 9 to check whether the professor is available at that particular time. There are 3 cases to consider. If the time entered is AM, display "Not Available" since the professor's office hours are in the late afternoon. If the time entered is PM, and it's within the office hour time, then display "Available" If the time entered is PM, but it's not within the office hour time, then display "Not Available". Use the String class equals method to check whether the entered time is "am" or "pm". To check the whether the entered time is during the office hours, use Java comparison and logical operators.
Step by Step Solution
★★★★★
3.52 Rating (149 Votes )
There are 3 Steps involved in it
Step: 1
import javautilScanner Class construction public class YourlastnameLab4 public static void mainStrin...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