Using Java in this task, you will use the switch statement to provide your activity of whole week. First, you
will ask to provide the number of the day, where number of a day means:
1 = Monday
2 = Tuesday
3 = Wednesday 4 = Thursday
5 = Friday
6 = Saturday
7 = Sunday
When the user provides a day number then you will print the statement that shows your lectures on that day and your other activities on that day. If a user provides any other number, then you will use the default option in the switch statement and will print out that “The provided number does not represent a day of the week”.
// Text code
// importing Scanner from util import java.util.Scanner; public class Routine { public static void main(String[] args){ // create object of Scanner class to get the input from keyboard Scanner scanner = new Scanner(System.in); // ask the user to enter a number System.out.print("Please enter number of the day: "); // get the day number int dayNumber = scanner.nextInt(); // switch the dayNumber switch (dayNumber){ // if it is Monday --> day 1 case 1: System.out.println("Today's course: Maths"); System.out.println("......Other activities......"); System.out.println("1. Watching movie with friends"); System.out.println("2. Going Gym"); break; // if it is Tuesday --> day 2 case 2: System.out.println("Today's course: Physics"); System.out.println("......Other activities......"); System.out.println("1. Morning walk"); System.out.println("2. Going Gym"); break; // if it is Wednesday --> day 3 case 3: System.out.println("Today's course: Data Structure And Algorithms"); System.out.println("......Other activities......"); System.out.println("1. Morning walk"); System.out.println("2. Going Gym"); break; // if it is Thursday --> day 4 case 4: System.out.println("Today's course: Chemistry"); System.out.println("......Other activities......"); System.out.println("1. Morning walk"); System.out.println("2. Going Gym"); break; // if it is Friday --> day 5 case 5: System.out.println("Today's course: Fuzzy Logic"); System.out.println("......Other activities......"); System.out.println("1. Morning walk"); System.out.println("2. Going Gym"); break; // if it is Saturday --> day 6 case 6: System.out.println("Today's course: Number Theory"); System.out.println("......Other activities......"); System.out.println("1. Morning walk"); System.out.println("2. Going Gym"); break; // if it is Sunday --> day 7 case 7: System.out.println("Today's course: No course"); System.out.println("......Other activities......"); System.out.println("1. Morning walk"); System.out.println("2. Going Gym"); System.out.println("3. Movies with friends"); break; //If a user provides any other number default: System.out.println("The provided number does not represent a day of the week."); } } }
// SCREENSHOTS
//code
//OUTPUTS
TEST CASE1:
TEST CASE2:
TEST CASE3:
Get Answers For Free
Most questions answered within 1 hours.