Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please be clear with your answer Create a program that generates a simple day sc

ID: 3848203 • Letter: P

Question

Please be clear with your answer Create a program that generates a simple day schedule with 3 activities, based upon the following inputs: m. Activity Name (Keep it to a short word if you are using tabs, or in the length range using a format0 or printf0 statement) 2. Activity Starting Hour (in military time, which is a 24 hr clock, acceptable numbers 1-24-do data validation) a Activity Ending Hour (in military time also) perform a validity check to be sure that this number is reater than or equal to Starting Hour 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 for0 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 -printf0 or formato 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

Explanation / Answer

I have done the prog using Java.

Code is fine and tested do not need to make any modification(other than designing part) unless and until it is atmost required.

import java.util.*;
import java.lang.*;

public class Acti
{
static String[][] act= new String[24][3];
static int stime,etime;

public static void main (String []a)       ////// main method ///////
{
Scanner sc= new Scanner(System.in);
int chk=0, chc;

String opt;
  
System.out.println("---- Welcome to the Activity Zone ----");

while(chk==0)
{
   choice: // label for 'choice' where it will return if improper input //
System.out.println("---- Press 1: For Eat 2: For Sleep 3: For School 4: Display Schedule ---- ---- ALERT 5: Will EXIT ----");
System.out.println("Enter your choice :");
chc= sc.nextInt();
  
switch(chc)
{
case 1: hour(1);   
    break;
case 2: hour(2);   
    break;   
case 3: hour(3);
    break;
case 4: disp();
    break;
case 5: System.exit(0);   
    break;
  
default:   
break choice;

}
}
}

static void hour(int val)
{
   Scanner sc= new Scanner(System.in);
  
   int actID=val;
  
   time: // label for 'time input' where it will return if improper input //
   System.out.println("Enter timings in 24 hour format(0-24).... Also Start time and End time cannot be same even End time cannot be greater than Start time :");
   System.out.println("Enter activity "+actID+" Start time :");
stime= sc.nextInt();
   System.out.println("Enter activity "+actID+" End time :");
etime= sc.nextInt();
  
if(stime>=0 && stime<etime && stime<=23) {System.out.println("Improper inputs.. Please give proper inputs"); break time;}
  
   if(etime<stime && etime>=1 && etime<=24) {System.out.println("Improper inputs.. Please give proper inputs"); break time;}

   store(actID, stime, etime);
  
}

   static void store(int val, int start, int end )
{
   int actID=val;
   int stime=start; int etime=end;

   for (int i=stime; i<=etime; i++)
   {
   if(actID == 1)
   act[i][1]="Eat";
   else if(actID == 2)
   act[i][2]="Sleep";
   else if(actID == 3)
   act[i][3]="School";
   }
  
   Scanner sc= new Scanner(System.in);
   System.out.println("Would like to see the activity table.... If yes press 1 else it will return to Main Menu");
   int inp= sc.nextInt();
if(inp == 1)
disp();


}

static void disp()
{
   System.out.println(" ***** My Schedule *****");
   System.out.println(" Hour Act1   Act2   Act3");
   for (int i=0; i<=24; i++)
   {
for(int j=0; j<=3; j++)
   System.out.println(i+" "+act[i][j] );
  
   }
  
  
}

}