Computer Science, asked by sanskarpatelanu, 4 months ago

Using switch case, write a program that allows to accept any values from 1 to 7 and

displays the weekdays corresponding to the number entered from the keyboard.

(Hint: 1 is Monday, 2 is Tuesday …..7 is Sunday)i​

Answers

Answered by scprasad004
3

Answer:

For case 1: print "MONDAY", for case 2: print "TUESDAY" and so on. Print "SUNDAY" for case 7: . If any case does not matches then, for default: case print "

Answered by Anonymous
2

Explanation:

}

// Get the name for the Week

public static String getDayName(int day) {

String dayName = "";

switch (day) {

case 1: dayName = "Monday"; break;

case 2: dayName = "Tuesday"; break;

case 3: dayName = "Wednesday"; break;

case 4: dayName = "Thursday"; break;

case 5: dayName = "Friday"; break;

case 6: dayName = "Saturday"; break;

case 7: dayName = "Sunday"; break;

default:dayName = "Invalid day range";

}

return dayName;

}

}

Similar questions