Write a Program to Print Week Days Using Switch in Java Programming

import java.util.Scanner;
public class Simple_Switch {
	public static void main(String[] args) {
		// take input form the User.
		Scanner userinput = new Scanner(System.in);
		System.out.println("Ente the Number(1-7) :");
		int daysNumber = userinput.nextInt();
		switch (daysNumber) {
		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("Firday");
			break;
		case 6:
			System.out.println("Saturady");
			break;
		case 7:
			System.out.println("Sunday");
			break;
		default:
			System.out.println(daysNumber + " Day does not Existed!!");
			break;
		}
		userinput.close();
	}
}

Output:

Simple_Switch

(Visited 2,792 times, 1 visits today)
Share with Friends :
Written by: