Computer Applications
Write a Java program to print the name of the day of the week using the switch case statement.
Sample Input:
Enter the day number: 1
Sample Output:
Sunday
Java
Java Conditional Stmts
18 Likes
Answer
import java.util.Scanner;
public class KboatDayOfWeek
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter the day number: ");
int n = in.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("Incorrect day.");
}
}
}Output

Answered By
6 Likes
Related Questions
The statement that brings the control back to the calling method is:
- break
- System.exit(0)
- continue
- return
Using the switch-case statement, write a menu driven program to do the following:
(a) To generate and print Letters from A to Z and their Unicode
Letters Unicode A 65 B 66 . . . . . . Z 90 (b) Display the following pattern using iteration (looping) statement:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5An air-conditioned bus charges fare from the passengers based on the distance travelled as per the tariff given below:
Distance Travelled Fare Up to 10 km Fixed charge ₹80 11 km to 20 km ₹6/km 21 km to 30 km ₹5/km 31 km and above ₹4/km Design a program to input distance travelled by the passenger. Calculate and display the fare to be paid.