Question

Using Java in this task, you will use the switch statement to provide your activity of...

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”.

Homework Answers

Answer #1

// 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:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
As a small restaurant owner, you are very interested in understanding the demand of your different...
As a small restaurant owner, you are very interested in understanding the demand of your different products. You have been collecting data over the past 11 weeks on the number of fish platter sales that you make each day. You want to run a simulation and you believe that 60% of your fish platter sales for a given week show up on the weekends (evenly split between Friday, Saturday and Sunday) while the remaining 40% are evenly divided across the...
A historic distribution information of people visit on a grocery store is: Monday: 10%; Tuesday 10%;...
A historic distribution information of people visit on a grocery store is: Monday: 10%; Tuesday 10%; Wednesday: 10%; Thursday: 15%; Friday: 15%; Saturday: 20%; Sunday 20%. The total is 100%. A test is conducted by counting the number of people visits each day: Monday: 150; Tuesday 110; Wednesday: 155; Thursday: 160; Friday: 180; Saturday: 240; Sunday: 190. Based on the information, can you conclude with 95% confidence that your test result agree with the historic information?
Days of the week Write a program that asks the user for a number in the...
Days of the week Write a program that asks the user for a number in the range of 1 through 7. The program should display the corresponding day of the week, where 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, and 7 = Sunday. The program should display an error message if the user enters a number that is outside of the range of 1 though 7.
The National Highway Traffic Safety Administration reported the percentage of traffic accidents occurring each day of...
The National Highway Traffic Safety Administration reported the percentage of traffic accidents occurring each day of the week. Assume that a sample of 420 accidents provided the following data. Sunday Monday Tuesday Wednesday Thursday Friday Saturday 69 47 54 49 58 69 74 a. Conduct a hypothesis test to determine if the proportion of traffic accidents is the same for each day of the week. What is the p-value? Compute the value of the X2 test statistic (to 3 decimals)....
Refactor the following program to use ArrayList instead of Arrays. You can google "Java ArrayList" or...
Refactor the following program to use ArrayList instead of Arrays. You can google "Java ArrayList" or start with the link below: https://www.thoughtco.com/using-the-arraylist-2034204 import java.util.Scanner; public class DaysOfWeeks { public static void main(String[] args) { String DAY_OF_WEEKS[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; char ch; int n; Scanner scanner = new Scanner(System.in); do { System.out.print("Enter the day of the Week: "); n = scanner.nextInt() - 1; if (n >= 0 && n <= 6) System.out.println("The day of the week is " + DAY_OF_WEEKS[n] + ".");...
Below you will find the closing stock prices for eBay over a three-week period. Calculate the...
Below you will find the closing stock prices for eBay over a three-week period. Calculate the simple three-day and five-day moving averages for the stock. (Round your answers to 2 decimal places.) Week Day Close 1 Monday $37.83 Tuesday 37.65 Wednesday 37.25 Thursday 37.51 Friday 36.77 2 Monday 36.94 Tuesday 37.01 Wednesday 37.05 Thursday 37.74 Friday 37.84 3 Monday 37.77 Tuesday 37.93 Wednesday 38.26 Thursday 38.41 Friday 38.24
Use the given categorical data to construct the relative frequency distribution. Natural births randomly selected from...
Use the given categorical data to construct the relative frequency distribution. Natural births randomly selected from four hospitals in a highly populated region occurred on the days of the week​ (in the order of Monday through​ Sunday) with the frequencies 54​, 63​, 71​, 57​, 55​, 45​, 55. Does it appear that such births occur on the days of the week with equal​ frequency? Construct the relative frequency distribution. Day Relative Frequency Monday nothing​% Tuesday nothing​% Wednesday nothing​% Thursday nothing​% Friday...
MW is a large discount store that operates seven days per week. The store needs the...
MW is a large discount store that operates seven days per week. The store needs the following number of full-time employees working each day of the week. Sunday Monday Tuesday Wednesday Thursday Friday Saturday num of employees 188 88 112 140 136 172 212 Each employee must work five consecutive days each week and then have two days off. For example, any employee who works Sunday through Thursday has Friday and Saturday off. The store currently has a total of...
So, the brewery selected it’s place and now needs to hire folks. After some testing, they...
So, the brewery selected it’s place and now needs to hire folks. After some testing, they expect to have approximately 2,000 customers per week. Since they will be open 7 days a week, they need to hire people to help serve their beer. They know that Friday and Saturday will drive sales. Between these 2 days, they will get 50% of their weekly sales. So, Friday has 25% of sales and Saturday has 25% of the sales. As for Sunday...
Need linear solution using Excel Solver. Cannot use an IF statement or it isn't linear. On...
Need linear solution using Excel Solver. Cannot use an IF statement or it isn't linear. On Monday morning, you have $3000 in cash on hand. For the next seven days, the following cash requirements must be met: Monday, $5000; Tuesday, $6000; Wednesday, $9000; Thursday, $2000; Friday, $7000; Saturday, $2000; Sunday, $3000. At the beginning of each day, you must decide how much money (if any) to withdraw from the bank. It costs $10 to make a withdrawal of any size....