LiFiUnit4.java - Main Method
Program will determine the hours you need to work based on certain criteria.
Program should get input for day of week as an integer: Monday = 1; Tuesday = 3; etc through Sunday = 7.
Program should get input for “Are You Sick” as a Boolean.
Logic required:
Use an if statement to determine the day of the week and if you are sick or not.
- If the day is Monday through Friday and you are NOT sick then perform the following:Using a switch statement, output:
- Monday and Wednesday output “Work Hours for today are 8-5”
- Tuesday output “Work Hours for today are 7-4”
- Friday output “Work Hours for today are 8-12”
- All
other days, output “Take the day off”. (this should only be called on
Thursday)All other days (Saturday and Sunday) output “Stay in bed!”Above
should be in a do while loop that should continue until I enter “y” at
the prompt: “Would you like to run again? (y/n)Mimic the output in the
sample below exactly.Sample
Enter the day of the week (, , , etc.): 1 Are you sick? (True or False): false Work Hours for today are 8-5Would you like to run again? (y/n) y Enter the day of the week (, , , etc.): 4 Are you sick? (True or False): false Take the day offWould you like to run again? (y/n) y Enter the day of the week (, , , etc.): 2 Are you sick? (True or False): true Stay in bed!
Would you like to run again? (y/n) y
Enter the day of the week (, , , etc.): 6
public class DailyWorkSchedule
{
public static void main (String[] args)
{
Scanner stdIn = new Scanner(System.in);
{System.out.print("Enter the day of the week (1=Mon, 2=Tue, 3=Wed, etc.):");
int myInt= stdIn.nextInt();
switch (myInt)
{
case 1:
System.out.println("Work hours for today are 8-5");
break;
case 2:
System.out.println("Work hours for today are 7-4");
break;
case 3:
System.out.println("Work hours for today are 8-5");
break;
case 4:
System.out.println("Take day off");
break;
case 5:
System.out.println("Work hours for today are 8-12");
break;
case 6:
System.out.println("Stay in bed!");
break;
case 7:
System.out.println("Stay in bed!");
break;
default:
System.out.println("Invalid"); }
system.out.print(are you sick?)
boolean sickClaim = stdIn.nextBoolean()
if (sickClaim == true)
{
system.out.println(Stay in bed!)
}
else
switch (workDay)
System.out.print("Would you like to run again? (y/n)");
more = stdIn.next().charAt(0);
}
} // end main
} // end DailyWorkSchedule