ホームページ  >  記事  >  バックエンド開発  >  非常に真面目な学生が書いたコード

非常に真面目な学生が書いたコード

WBOY
WBOYオリジナル
2016-07-25 09:08:15754ブラウズ
  1. package com.qimenguigu.l07131;
  2. import java.io.BufferedReader;
  3. import java.io.IOException;
  4. import java.io.InputStreamReader;
  5. /**
  6. * 年、月、日、次|前を入力し、正しい日付の場合は前後の日を計算します
  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. 文字列 s2 = br.readLine();
  18. System.out.println("请输入日份");
  19. 文字列 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 && 月 if (月 == 1 || 月 == 3 || 月 == 5 || 月 == 7
  24. || 月 == 8 || 月 == 10 || month == 12) {
  25. if (day >= 1 && day <= 31) {
  26. System.out.println("您输入的日期:" + year + "年" + month + "月"
  27. + day + "日");
  28. if (day == 31) {
  29. if (month == 12)
  30. System.out.println("そして上一天:" + year + "年12月"
  31. + ( day - 1) + "日" + "," + "下一天範囲:"
  32. + (年 + 1) + "年1月1日");
  33. else
  34. System.out.println(" そして上一天範囲:" + year + "年" + month
  35. + "月" + (day - 1) + "日" + "," + "下一天是:"
  36. + year + "年" + (month + 1) + "月1日");
  37. } else if (日 == 1) {
  38. if (月 == 1)
  39. System.out.println("そして上一天:" + (年 - 1)
  40. + "年12月31日" + "," + "下一天為:" + year + "年"
  41. + month + "月" + (day + 1) + "日");
  42. else if (month == 3) {
  43. if ((年 % 4 == 0 && 年 % 100 != 0)
  44. || (年 % 400 == 0))
  45. System.out.println("そして上一天の場合:" + year + "年2月29日"
  46. + "," + "下一天の場合:" + year + "年" + month
  47. + "月" + (day + 1) + "日");
  48. else
  49. System.out.println("そして上一天:" + year + "年2月28日"
  50. + ", " + "下一天の場合:" + year + "年" + month
  51. + "月" + (day + 1) + "日");
  52. } else
  53. System.out.println("そして上一天の場合:" +年 + "年"
  54. + (月 - 1) + "月30日" + "," + "下一天:"
  55. + 年 + "年" + 月 + "月" + (日 + 1)
  56. + "日");
  57. } else
  58. System.out.println("そして上一天:" + year + "年" + month + "月"
  59. + (day - 1) + "日" + "," + "下一天:" + year + "年"
  60. + month + "月" + (day + 1) + "日");
  61. } else
  62. System.out.println("您输入的日期不法" );
  63. } else if (月 == 4 || 月 == 6 || 月 == 9 || 月 == 11) {
  64. if (日 >= 1 && 日 システム。 out.println("您输入的日期:" + year + "年" + month + "月"
  65. + day + "日");
  66. if (day == 30)
  67. System.out.println(" そして上一天の場合:" + year + "年" + month + "月"
  68. + (day - 1) + "日" + "," + "下一天の場合:" + year + "年"
  69. + (month + 1) + "月1日");
  70. else if (day == 1)
  71. System.out.println("そして上一天:" + year + "年" + (month - 1)
  72. + "月31日" + "," + "下一天の場合:" + year + "年" + month
  73. + (day + 1) + "日");
  74. else
  75. System.out.println("そして上一天の場合:" + 年 + "年" + 月 + "月"
  76. + (日 - 1) + "日" + "," + "下一天:" + 年 + "年"
  77. + 月 + (日 + 1) + "日");
  78. } else
  79. System.out.println("您输入的日期不法");
  80. }else if ((年 % 4 == 0 && 年 % 100 != 0) || (年 % 400 == 0)) {
  81. if (日 == 29)
  82. System.out.println("入力した日付それは、「 + year + "year" + month + "month"
  83. + day + "day" + "n" + "であり、前日は次のようになります: " + year + "2月28日"
  84. + "," + "次の日は:" + 年 + "その年の 3 月 1 日");
  85. else {
  86. if (day == 28)
  87. System.out.println("入力した日付は次のとおりです:" + 年 + "年" + month
  88. + "month" + day + "day" + "n" + "そして、前日は:" + year
  89. + "その年の 2 月 27 日" + "," + "次の日は:" + year + "年 2 月 29 日");
  90. else
  91. System.out.println("入力された日付は不正です");
  92. }
  93. }
  94. } else
  95. System.out.println("入力された日付は不正です" );
  96. }
  97. }
コードをコピー


声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。