Computer Applications
Write a Java program using the switch case to print the corresponding days of numbers.
For example: 1= Monday…. 7 = Sunday
Java
Java Conditional Stmts
46 Likes
Answer
public class KboatDayName
{
public static void dayName(int n) {
switch (n) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
case 4:
System.out.println("Thursday");
break;
case 5:
System.out.println("Friday");
break;
case 6:
System.out.println("Saturday");
break;
case 7:
System.out.println("Sunday");
break;
default:
System.out.println("Incorrect day.");
}
}
}
Output
Answered By
14 Likes
Related Questions
Write a program to print all the prime numbers between 1 and 100.
Generate the following series upto 10 terms:
1, 4, 7,10 ……
Write a program to print the largest of three numbers.
Write a program to print the Fibonacci series upto 10 terms.
[A series of numbers in which each number is the sum of the two preceding numbers.For example: 0,1,1,2,3, …………… n].