Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Grading Rubric (for Instructions) YournameLab4.java Basics (25 pts, or -100 pts) File is named wrongly (You did not use your name ). (-100 pts, you

Grading Rubric (for Instructions)

YournameLab4.java

Basics (25 pts, or -100 pts)

File is named wrongly (You did not use your name). (-100 pts, you get 0 for this assignment, resubmit allowed, late penalty applies)

Student handed in wrong file. (-100 pts, you get 0, resubmission allowed, late penalty applies.)

Program code does not compile / run. (-50 pts, resubmission allowed, late penalty applies.)

File contains package statement for package csci1011.lab4. (5 pt)

Comments include student name, class, and description of assignment. (10 pts)

Declares a class with the correct class name. (5 pts)

Code is properly indented. (5 pts)

Input (35 pts)

Reads the day of the week into a String variable. (5 pts)

Reads the time of day into a String variable. (5 pts)

Correctly extracts hour and converts result to an integer. (5 pts)

Correctly extracts minutes and converts result to an integer. (5 pts)

Correctly extracts AM/PM. (5 pts)

Validates hour and minutes. (5 pts)

Validates day of the week. (5 pts)

Processing and Output (40 pts)

Determines if the day is Monday. (5 pts)

Correctly determines availability for Monday. (5 pts)

Determines if the day is Thursday. (5 pts)

Correctly determines availability for Thursday. (5 pts)

Determines if the day is Friday. (5 pts)

Correctly determines availability for Friday. (5 pts)

Determines if the day is Tuesday, Wednesday, Sunday or Saturday. (5 pts)

Correctly determines availability for Tuesday, Wednesday, Sunday, or Saturday. (5 pts)

Instructions

The office hours for Professor X in Spring 2021 are as follows:

onday 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 NetBeans.

Create a new project called Lab4 with a main class called YournameLab4 with your 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:

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.

number = Integer.parseInt("42"); // converts "42" to 42

Use if-else statements to display the entered day of the week in the following format:

of the week: Monday

the String class equalsIgnoreCase 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.

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 professors office hours are in the late afternoon.

If the time entered is PM, and its within the office hour time, then display "Available"

If the time entered is PM, but its not within the office hour time, then display "Not Available".

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.

The output from your program should look like the following:

output 1:

the day of the week: Monday Enter a time (XX:XXam/pm): 3:45pm Day of the week: Monday Available

output 2:

the day of the week: Friday Enter a time (XX:XXam/pm): 04:45pm Day of the week: Friday Not Available

output 3:

the day of the week: thu Enter a time (XX:XXam/pm): 2:00pm Day of the week: thu Not Available

output 4:

the day of the week: wed Enter a time (XX:XXam/pm): 9:00am Day of the week: wed Not Available

output 5:

the day of the week: MON Enter a time (XX:XXam/pm): 10:30am Day of the week: MON Not available

Add logic to your program to perform input validation for the hour, minute, and day. If any of these have invalid input, display an error message. The output of your program in these cases should look like this:

output 1:

the day of the week: MON Enter a time (XX:XXam/pm): 4:63am Invalid time

Sample output 2:

the day of the week: Flursday Enter a time (XX:XXam/pm): 11:12pm Invalid day

Make sure your code is indented properly and you have CSCI 1011 Lab 4, your name, and a brief description of your program in the Javadoc comments before the class declaration.

Upload the file YournameLab4.java to the drop box folder labeled Lab Assignment

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions