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


stdout
Enter week's day using a number
Wednesday