import java.util.Scanner;
public class even {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter a number ranging from 1- 7 to know the corresponding month");
int range = input.nextInt();
while (range <1 || range >7){ // keeps the user in this loop as long as the condition remain true//
System.out.println("You have enter an invalid number");
System.out.println("Enter a number ranging from 1- 7 to know the corresponding month");
range = input.nextInt();
}
switch (range){ // This checks the input from the user and print the condition that meets the corresponding case
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("Thrusday");
break;
case 6:
System.out.println("Friday");
break;
case 7:
System.out.println("Saturday");
break;
}
}
}
Comments
Post a Comment