Having issues getting the correct output for this. Specific language should be j
ID: 3763862 • Letter: H
Question
Having issues getting the correct output for this. Specific language should be java.
SPECIFICS:
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 = 2; etc through Sunday = 7.
Program should get input for “Are You Sick” as a Boolean.
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 output "I hate Mondays, Work Hours for today are 8-5"
Wednesday output “Work Hours for today are 8-5”
Tuesday output “Work Hours for today are 7-4”
Friday output “SWEET it is Friday, Noon can't get here fast enough, 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! Unless you have a to do list”
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)
The sample output should reflect this:
Enter the day of the week (1=Mon, 2=Tue, 3=Wed, etc.): 3
Are you sick? (True or False): false
Work Hours for today are 8-5
Would you like to run again? (y/n) y
Enter the day of the week (1=Mon, 2=Tue, 3=Wed, etc.): 4
Are you sick? (True or False): false
Take the day off
Would you like to run again? (y/n) y
Enter the day of the week (1=Mon, 2=Tue, 3=Wed, 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 (1=Mon, 2=Tue, 3=Wed, etc.): 6
Are you sick? (True or False): false
Stay in bed! Unless you have a to do list
Would you like to run again? (y/n) n
Explanation / Answer
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);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.