Advertisement
veronikaaa86

05. Month Printer

May 18th, 2022
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. package basicSyntax;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P05MonthPrinter {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int num = Integer.parseInt(scanner.nextLine());
  10.  
  11. String month = "";
  12. switch (num) {
  13. case 1:
  14. month = "January";
  15. break;
  16. case 2:
  17. month = "February";
  18. break;
  19. case 3:
  20. month = "March";
  21. break;
  22. case 4:
  23. month = "April";
  24. break;
  25. case 5:
  26. month = "May";
  27. break;
  28. case 6:
  29. month = "June";
  30. break;
  31. case 7:
  32. month = "July";
  33. break;
  34. case 8:
  35. month = "August";
  36. break;
  37. case 9:
  38. month = "September";
  39. break;
  40. case 10:
  41. month = "October";
  42. break;
  43. case 11:
  44. month = "November";
  45. break;
  46. case 12:
  47. month = "December";
  48. break;
  49. default:
  50. month = "Error!";
  51. }
  52.  
  53. System.out.println(month);
  54. }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement