fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. // SwitchExercises
  5.  
  6. public static void main (String[] args) {
  7. System.out.println("Enter week's day using a number");
  8. Scanner scanner = new Scanner(System.in);
  9. int dayOfWeek = scanner.nextInt();
  10. String weekTitle;
  11.  
  12. if (dayOfWeek == 1) {
  13. weekTitle = "Monday";
  14. } else if (dayOfWeek ==2) {
  15. weekTitle = "Tuesday";
  16. } else if (dayOfWeek ==3) {
  17. weekTitle = "Wednesday";
  18. } else if (dayOfWeek ==4) {
  19. weekTitle = "Thursday";
  20. } else if (dayOfWeek ==5) {
  21. weekTitle = "Friday";
  22. } else if (dayOfWeek ==6) {
  23. weekTitle = "Saturday";
  24. } else if (dayOfWeek ==7) {
  25. weekTitle = "Sunday";
  26. } else {
  27. weekTitle = "Entered unknown item";
  28. }
  29.  
  30. System.out.println(weekTitle);
  31. scanner.close();
  32. }
  33. }
  34.  
Success #stdin #stdout 0.17s 54688KB
stdin
5
stdout
Enter week's day using a number
Friday