标签:div 这一 default port string main auth amp stat
import java.util.Scanner; /** * @author 蓝色以太 输入某年某月某日,判断这一天是这一年的第几天? */ public class CalculateDay { public static void main(String[] args) { int y, m, d, F = 28, A = 0; Scanner sc = new Scanner(System.in); System.out.println("请正确输入年份:"); y = sc.nextInt(); System.out.println("请正确输入月份:"); m = sc.nextInt(); System.out.println("请正确输入日期:"); d = sc.nextInt(); if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) { F = 29; A = 1; } switch (m) { case 1: { if (d < 1 || d > 31) { System.out.println("输入的日期有误!"); } break; } case 2: { if (d >= 1 && d <= 29 && A == 1) { d = d + 31; } else if (d >= 1 && d <= 28) { d = d + 31; } else { System.out.println("输入的日期有误!"); } break; } case 3: { if (d >= 1 && d <= 31) { d = d + 31 + F; } else { System.out.println("输入的日期有误!"); } break; } case 4: { if (d >= 1 && d <= 30) { d = d + 31 + F + 31; } else { System.out.println("输入的日期有误!"); } break; } case 5: { if (d >= 1 && d <= 31) { d = d + 31 + F + 31 + 30; } else { System.out.println("输入的日期有误!"); } break; } case 6: { if (d >= 1 && d <= 30) { d = d + 31 + F + 31 + 30 + 31; } else { System.out.println("输入的日期有误!"); } break; } case 7: { if (d >= 1 && d <= 31) { d = d + 31 + F + 31 + 30 + 31 + 30; } else { System.out.println("输入的日期有误!"); } break; } case 8: { if (d >= 1 && d <= 31) { d = d + 31 + F + 31 + 30 + 31 + 30 + 31; } else { System.out.println("输入的日期有误!"); } break; } case 9: { if (d >= 1 && d <= 30) { d = d + 31 + F + 31 + 30 + 31 + 30 + 31 + 31; } else { System.out.println("输入的日期有误!"); } break; } case 10: { if (d >= 1 && d <= 31) { d = d + 31 + F + 31 + 30 + 31 + 30 + 31 + 31 + 30; } else { System.out.println("输入的日期有误!"); } break; } case 11: { if (d >= 1 && d <= 30) { d = d + 31 + F + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31; } else { System.out.println("输入的日期有误!"); } break; } case 12: { if (d >= 1 && d <= 31) { d = d + 31 + F + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30; } else { System.out.println("输入的日期有误!"); } break; } default: System.out.println("月份有误,请重新输入"); } System.out.println("这一天是这一年的第" + d + "天"); } }
标签:div 这一 default port string main auth amp stat
原文地址:http://www.cnblogs.com/lanseyitai1224/p/7011477.html