Question
Assume the int variable dayOfWeek has some value, and that it follows this rule: 1 = Monday 2 = Tuesday 3 = Wednesday 4 =
Assume the int variable dayOfWeek has some value, and that it follows this rule:
1 = Monday
2 = Tuesday
3 = Wednesday
4 = Thursday
5 = Friday
6 = Saturday
7 = Sunday
Declare a String variable called schedule and write a switch statement that gives schedule a different value based on the day of the week. For Monday, give it the value Gym in the morning." For Tuesday give it the value Class after work." For Wednesday, give it the value
Meetings all day." For Thursday give it the value Work from home." For Friday, give it the value Game night after work." For Saturday and Sunday, give it the value Free!" This should also be the default value.
Starting code:
//Assume this can have any value from 1 to 7:
int dayOfWeek = 1;
//TODO: declare a String variable called schedule.
//TODO: write a switch statement that give schedule a different
//value for each day of the week based on the dayOfWeek variable.
//Dont forget to "break" after each case, and dont forget to
//provide a default case!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started