Sunday, 5 November 2017

java program that check days of week



Problem 13:
Write a program that check days of weak
Descriptions:
Using switch statement
Solution:
import java.util.*;
public class Message {
 public static void main(String[] args) {
 
 Scanner input = new Scanner(System.in);

 System.out.print("Enter number of day: ");
 int year = input.nextInt();

 switch (year % 12) {
 case 0: System.out.println("Monday"); break;
 case 1: System.out.println("Tuesday"); break;
 case 2: System.out.println("Wednesday"); break;
 case 3: System.out.println("Thursday"); break;
 case 4: System.out.println("Friday"); break;
 case 5: System.out.println("Saturday"); break;
 case 6: System.out.println("Sunday");
 default:
     System.out.println("Wrong entery");
 }
 }
Output:

No comments:

Post a Comment