A very serious student writing code

Source: Internet
Author: User
<无详细内容>
  1. Package com.qimenguigu.l07131;
  2. Import Java.io.BufferedReader;
  3. Import java.io.IOException;
  4. Import Java.io.InputStreamReader;
  5. /**
  6. * Enter the year, month, day, Next|prior, if it is a correct date, calculate the previous day or the next day
  7. *
  8. * @author Longjie
  9. * @website www.qimenguigu.com
  10. */
  11. public class Title15 {
  12. public static void Main (string[] args) throws IOException {
  13. BufferedReader br = new BufferedReader (new InputStreamReader (system.in));
  14. System.out.println ("Please enter the Year");
  15. String S1 = Br.readline ();
  16. System.out.println ("Please enter the month");
  17. String s2 = br.readline ();
  18. System.out.println ("Please enter a Japanese copy");
  19. String s3 = Br.readline ();
  20. int year = Integer.parseint (S1);
  21. int month = integer.parseint (S2);
  22. int day = Integer.parseint (S3);
  23. if (year >= 0 && month >= 1 && month <= 12) {
  24. if (month = = 1 | | month = = 3 | | month = = 5 | | month = = 7
  25. || Month = = 8 | | Month = = 10 | | month = = 12) {
  26. if (Day >= 1 && Day <= 31) {
  27. SYSTEM.OUT.PRINTLN ("You entered the date:" + year + "years" + month + "month")
  28. + Day + "Days");
  29. if (day = = 31) {
  30. if (month = = 12)
  31. System.out.println ("and the previous day is:" + year + "Years December"
  32. + (DAY-1) + "Day" + "," + "Next day for:"
  33. + (year + 1) + "January 1");
  34. Else
  35. System.out.println ("and the previous day is:" + year + "years" + month
  36. + "Month" + (DAY-1) + "Day" + "," + "Next day for:"
  37. + year + "years" + (month + 1) + "1st");
  38. } else if (day = = 1) {
  39. if (month = = 1)
  40. System.out.println ("and the previous day is:" + (YEAR-1)
  41. + "Year December 31" + "," + "Next day:" + year + "Years"
  42. + month + "months" + (day + 1) + "Days");
  43. else if (month = = 3) {
  44. If ((year% 4 = = 0 && Year% 100! = 0)
  45. || (Year% 400 = = 0))
  46. System.out.println ("And Last day:" + year + "February 29"
  47. + "," + "Next day for:" + year + "years" + month
  48. + "Month" + (day + 1) + "Days");
  49. Else
  50. System.out.println ("And Last day:" + year + "February 28"
  51. + "," + "Next day for:" + year + "years" + month
  52. + "Month" + (day + 1) + "Days");
  53. } else
  54. System.out.println ("and the previous day is:" + year + "Years"
  55. + (month-1) + "Month 30th" + "+" Next day for: "
  56. + year + "years" + month + "month" + (day + 1)
  57. + "Day");
  58. } else
  59. System.out.println ("Last day:" + year + "years" + month + "month")
  60. + (DAY-1) + "Day" + "+" Next day for: "+ year +" Years "
  61. + month + "months" + (day + 1) + "Days");
  62. } else
  63. System.out.println ("The date you entered is not valid");
  64. } else if (month = = 4 | | month = = 6 | | month = = 9 | | month = = 11) {
  65. if (Day >= 1 && Day <= 30) {
  66. SYSTEM.OUT.PRINTLN ("You entered the date:" + year + "years" + month + "month")
  67. + Day + "Days");
  68. if (day = = 30)
  69. System.out.println ("Last day:" + year + "years" + month + "month")
  70. + (DAY-1) + "Day" + "+" Next day for: "+ year +" Years "
  71. + (month + 1) + "1st");
  72. else if (day = = 1)
  73. System.out.println ("and the previous day is:" + year + "years" + (MONTH-1)
  74. + "Month 31st" + "+" Next day for: "+ year +" years "+ month
  75. + (day + 1) + "Days");
  76. Else
  77. System.out.println ("Last day:" + year + "years" + month + "month")
  78. + (DAY-1) + "Day" + "+" Next day for: "+ year +" Years "
  79. + Month + (day + 1) + "Days");
  80. } else
  81. System.out.println ("The date you entered is not valid");
  82. } else if ((year% 4 = = 0 && Year% 100! = 0) | | (Year% 400 = = 0)) {
  83. if (day = = 29)
  84. SYSTEM.OUT.PRINTLN ("You entered the date:" + year + "years" + month + "month")
  85. + Day + "daily" + "\ n" + "and the previous day is:" + year + "February 28"
  86. + "," + "Next day for:" + year + "March 1");
  87. else {
  88. if (day = = 28)
  89. SYSTEM.OUT.PRINTLN ("You entered the date:" + year + "years" + month
  90. + "Month" + Day + "daily" + "\ n" + "and the previous day is:" + year
  91. + "February 27" + "," + "Next day for:" + year + "February 29");
  92. Else
  93. System.out.println ("The date you entered is not valid");
  94. }
  95. }
  96. } else
  97. System.out.println ("The date you entered is not valid");
  98. }
  99. }
Copy Code
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.