Computer Science, asked by dharshinirajkumar200, 7 months ago

Using the switch statement, write a menu driven program :
(i) To check and display a number input by the user and display the respective day.
for example
input :1
output :SUNDAY
input : 3
output : TUESDAY
input :8
output :INVALID
For an incorrect choice, an appropriate error message should be displayed

Answers

Answered by CopyThat
5

Program, {JAVA}:

import java.util.*;

public class Brainly

{

static void main()

{

Scanner sc=new Scanner(System.in);

int n;

System.out.println("Enter any day number between 1 to 7");

n=sc.nextInt();

switch(n)

{

case 1:

System.out.println("Sunday");

break;

case 2:

System.out.println("Monday");

break;

case 3:

System.out.println("Tuesday");

break;

case 4:

System.out.println("Wednesday");

break;

case 5:

System.out.println("Thursday");

break;

case 6:

System.out.println("Friday");

break;

case 7:

System.out.println("Saturday");

break;

default:

System.out.println("Invalid day number");

}

}

}

Similar questions