Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please do it as a Java (.java) Create a program that generates a simple day schedule with 3 activities, based upon the following

Can you please do it as a Java (.java)

Create a program that generates a simple day schedule with 3 activities, based upon the following inputs:

1-Activity Name (Keep it to a short word if you are using tabs, or in the length range using a .format() or .printf() statement)

2-Activity Starting Hour (in military time, which is a 24 hr clock, acceptable numbers 1-24 do data validation)

3-Activity Ending Hour (in military time also) perform a validity check to be sure that this number is greater than or equal to Starting Hour

4-Hints:

.Activities do not have to be entered in chronological order, but there should be no overlapping. Start/End numbers are inclusive.

.Utilize a nested loop, the outer loop goes from 1..24 for the hour of day.

.For each iteration of the outer loop, have an inner for() loop that goes from col=1 to col=3

.Use a switch statement to test for the case of 1, 2, and 3 to represent each of 3 cols/activities. Then, under the case, use an if statement to test if the hour falls between the start/end time for this activity. Then perform the output of the activity into the appropriate column (tabs work here, or you can use the .printf() or .format() method, which is preferred. If using tabs, you can tab out when processing activity 1 - two tabs, activity 2 - three tabs, and activity 3 - four tabs, for example.

.Perform data validation to prevent bad input.

.This program requires at least 3 variables for each of the 3 activities you are logging, and 2 loop counter variables.

.Arrays are not necessary, but if you want to use them you may.

Sample Output:

Enter activity 1 name: Eat

Enter activity 1 starting hour: 12

Enter activity 1 ending hour: 14

Enter activity 2 name: Sleep

Enter activity 2 starting hour: 1

Enter activity 2 ending hour: 9

Enter activity 3 name: School

Enter activity 3 starting hour: 16

Enter activity 3 ending hour: 22

My Schedule

Hour Act1 Act2 Act3

1 Sleep

2 Sleep

3 Sleep

4 Sleep

5 Sleep

6 Sleep

7 Sleep

8 Sleep

9 Sleep

10

11

12 Eat

13 Eat

14 Eat

15

16 School

17 School

18 School

19 School

20 School

21 School

22 School

23

24

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

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions