这个java怎么老是通不过编译,欢迎各位指导下!!
importjava.util.Scanner;classSwitchDemo4{publicstaticvoidmain(String[]args){Scanners=...
import java.util.Scanner;class SwitchDemo4 { public static void main(String[] args){ Scanner s = new Scanner(System.in); System.out.println("请输入年"); int n = s.nextInt(); System.out.println("请输入月"); int y = s.nextInt(); System.out.println("请输入日"); int r = s.nextInt(); int s = 0; switch( y-1 ) { case 11 : s += 30; case 10: s += 31; case 9: s += 30; case 8: s += 31; case 7: s += 31; case 6: s += 30; case 5: s += 31; case 4: s += 30; case 3: s += 31; case 2 : if {(n%4==0&&n%100!=0||n%400==0) s += 29}; esle {s += 28}; case 1 : s += 31; } s += r; System.out.println(n+ "年" +y+ "月" +r+ "日在这一年已经过去的天数:" +s);}; };
展开
3个回答
2016-09-01
展开全部
import java.util.Scanner;
class SwitchDemo4 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入年");
int n = scanner.nextInt();
System.out.println("请输入月");
int y = scanner.nextInt();
System.out.println("请输入日");
int r = scanner.nextInt();
int s = 0;
switch (y - 1) {
case 11:
s += 30;
case 10:
s += 31;
case 9:
s += 30;
case 8:
s += 31;
case 7:
s += 31;
case 6:
s += 30;
case 5:
s += 31;
case 4:
s += 30;
case 3:
s += 31;
case 2:
if (n % 4 == 0 && n % 100 != 0 || n % 400 == 0) {
s += 29;
} else {
s += 28;
}
case 1:
s += 31;
}
s += r;
System.out.println(n + "年" + y + "月" + r + "日在这一年已经过去的天数:" + s);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询