Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. public class FindNumberOfDaysInMonth_03_11 {
  2. public static void main(String[] args) {
  3. java.util.Scanner input = new java.util.Scanner(System.in);
  4. // Prompt the user to enter input
  5. __________._______._________("Enter a month in the year (e.g., 1 for Jan): ");
  6. _____ month = ________.____________();
  7.  
  8. System.out.print("Enter a year: ");
  9. int __________ = _______.___________();
  10.  
  11. int numberOfDaysInMonth = __;
  12.  
  13. switch (month) {
  14. case 1:
  15. System.out.print("January " + year);
  16. numberOfDaysInMonth = 31;
  17. break;
  18. case 2:
  19. System.out.print("February " + year);
  20. if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
  21. numberOfDaysInMonth = 29;
  22. }
  23. else {
  24. numberOfDaysInMonth = 28;
  25. }
  26. break;
  27. case 3:
  28. System.out.print("March " + year);
  29. numberOfDaysInMonth = 31;
  30. break;
  31. case 4:
  32. System.out.print("April " + year);
  33. numberOfDaysInMonth = 30;
  34. break;
  35. case 5:
  36. System.out.print("May " + year);
  37. numberOfDaysInMonth = 31;
  38. break;
  39. case 6:
  40. System.out.print("June " + year);
  41. numberOfDaysInMonth = 30;
  42. break;
  43. case 7:
  44. System.out.print("July " + year);
  45. numberOfDaysInMonth = 31;
  46. break;
  47. case 8:
  48. System.out.print("August " + year);
  49. numberOfDaysInMonth = 31;
  50. break;
  51. case 9:
  52. System.out.print("September " + year);
  53. numberOfDaysInMonth = 30;
  54. break;
  55. case 10:
  56. System.out.print("October " + year);
  57. numberOfDaysInMonth = 31;
  58. break;
  59. case 11:
  60. System.out.print("November " + year);
  61. numberOfDaysInMonth = 30;
  62. break;
  63. case 12:
  64. System.out.print("December " + year);
  65. numberOfDaysInMonth = 31;
  66. break;
  67. }
  68.  
  69. System.out.print(" has " + numberOfDaysInMonth + " days");
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement