Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.lang.Math;
  3.  
  4.  
  5. class Main {
  6. public static void main(String[] args) {
  7. Scanner scan = new Scanner(System.in);
  8. int x;
  9. String y;
  10. y = null;
  11. x = 0;
  12. System.out.println("Please enter the date in number form.");
  13. System.out.println("Month:");
  14. int month = scan.nextInt();
  15. System.out.println("Day:");
  16. int day = scan.nextInt();
  17. System.out.println("Year:");
  18. int year = scan.nextInt();
  19.  
  20.  
  21. {if (year %4 != 0){
  22. x = 0;
  23. }if (month == 3){
  24. x = 59;
  25. y = "March";
  26. }if (month == 4){
  27. x = 90;
  28. y = "April";
  29. }if (month == 5){
  30. x = 120;
  31. y = "May";
  32. }if (month == 6){
  33. x = 151;
  34. y = "June";
  35. }if (month == 7){
  36. x = 181;
  37. y = "July";
  38. }if (month == 8){
  39. x = 212;
  40. y = "August";
  41. }if (month == 9){
  42. x = 243;
  43. y = "September";
  44. }if (month == 10){
  45. x = 273;
  46. y = "October";
  47. }if (month == 11){
  48. x = 304;
  49. y = "November";
  50. }if (month == 12){
  51. x = 334;
  52. y = "December";
  53. }if (month >= 12){
  54. x = 0;
  55. y = null;
  56. System.out.println("Please re-enter your date correctly in number form.");
  57. }
  58.  
  59. else if (year%4 == 0){
  60. x = 0;
  61. }else if (month == 1){
  62. x = 0;
  63. y = "January";
  64. }if (month == 2){
  65. x = 31;
  66. y = "February";
  67. }else if (month == 3){
  68. x = 60;
  69. y = "March";
  70. }else if (month == 4){
  71. x = 91;
  72. y = "April";
  73. }else if (month == 5){
  74. x = 121;
  75. y = "May";
  76. }else if (month == 6){
  77. x = 152;
  78. y = "June";
  79. }else if (month == 7){
  80. x = 182;
  81. y = "July";
  82. }else if (month == 8){
  83. x = 213;
  84. y = "August";
  85. }else if (month == 9){
  86. x = 244;
  87. y = "September";
  88. }else if (month == 10){
  89. x = 274;
  90. y = "October";
  91. }else if (month == 11){
  92. x = 305;
  93. y = "November";
  94. }else if (month == 12){
  95. x = 335;
  96. y = "December";
  97. }else if (month >= 12){
  98. x = 0;
  99. y = null;
  100. System.out.println("Please re-enter your date correctly in number form.");
  101. }if (day == 1){
  102. System.out.println("Your date is in the month of "+ y +" and the "+ (x + day) +"st day of the year");
  103. }else{
  104. System.out.println("Your date is in the month of "+ y +" and the "+ (x + day) +"th day of the year");}
  105. }
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement