Code written by a very serious student

WBOY
Release: 2016-07-25 09:08:15
Original
791 people have browsed it
  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 or 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("请输入年份");
  15. String s1 = br.readLine();
  16. System.out.println("请输入月份");
  17. String s2 = br.readLine();
  18. System.out.println("请输入日份");
  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("您输入的日期为:" + year + "年" + month + "月"
  28. + day + "日");
  29. if (day == 31) {
  30. if (month == 12)
  31. System.out.println("且上一天为:" + year + "年12月"
  32. + (day - 1) + "日" + "," + "下一天为:"
  33. + (year + 1) + "年1月1日");
  34. else
  35. System.out.println("且上一天为:" + year + "年" + month
  36. + "月" + (day - 1) + "日" + "," + "下一天为:"
  37. + year + "年" + (month + 1) + "月1日");
  38. } else if (day == 1) {
  39. if (month == 1)
  40. System.out.println("且上一天为:" + (year - 1)
  41. + "年12月31日" + "," + "下一天为:" + year + "年"
  42. + month + "月" + (day + 1) + "日");
  43. else if (month == 3) {
  44. if ((year % 4 == 0 && year % 100 != 0)
  45. || (year % 400 == 0))
  46. System.out.println("且上一天为:" + year + "年2月29日"
  47. + "," + "下一天为:" + year + "年" + month
  48. + "月" + (day + 1) + "日");
  49. else
  50. System.out.println("且上一天为:" + year + "年2月28日"
  51. + "," + "下一天为:" + year + "年" + month
  52. + "月" + (day + 1) + "日");
  53. } else
  54. System.out.println("且上一天为:" + year + "年"
  55. + (month - 1) + "月30日" + "," + "下一天为:"
  56. + year + "年" + month + "月" + (day + 1)
  57. + "日");
  58. } else
  59. System.out.println("且上一天为:" + year + "年" + month + "月"
  60. + (day - 1) + "日" + "," + "下一天为:" + year + "年"
  61. + month + "月" + (day + 1) + "日");
  62. } else
  63. System.out.println("您输入的日期不合法");
  64. } else if (month == 4 || month == 6 || month == 9 || month == 11) {
  65. if (day >= 1 && day <= 30) {
  66. System.out.println("您输入的日期为:" + year + "年" + month + "月"
  67. + day + "日");
  68. if (day == 30)
  69. System.out.println("且上一天为:" + year + "年" + month + "月"
  70. + (day - 1) + "日" + "," + "下一天为:" + year + "年"
  71. + (month + 1) + "月1日");
  72. else if (day == 1)
  73. System.out.println("且上一天为:" + year + "年" + (month - 1)
  74. + "月31日" + "," + "下一天为:" + year + "年" + month
  75. + (day + 1) + "日");
  76. else
  77. System.out.println("且上一天为:" + year + "年" + month + "月"
  78. + (day - 1) + "日" + "," + "下一天为:" + year + "年"
  79. + month + (day + 1) + "日");
  80. } else
  81. System.out.println("您输入的日期不合法");
  82. }else if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
  83. if (day == 29)
  84. System.out.println("The date you entered It is: " + year + "year" + month + "month"
  85. + day + "day" + "n" + "And the previous day is: " + year + "February 28th"
  86. + "," + "The next day is:" + year + "March 1st of the year");
  87. else {
  88. if (day == 28)
  89. System.out.println("The date you entered is:" + year + "Year" + month
  90. + "month" + day + "day" + "n" + "And the previous day is:" + year
  91. + "February 27th of the year" + "," + "The next day is:" + year + "February 29, year");
  92. else
  93. System.out.println("The date you entered is illegal");
  94. }
  95. }
  96. } else
  97. System.out.println("The date you entered is illegal" );
  98. }
  99. }
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template