判断闰年的程序
import java.io.*;
public class Leap{
public static void main (String args[]){
InputStreamReader isr=new InputStreamReader(System in)=
BufferedReader; br=new BufferedReader(isr);
System.out.println("请输入一个年份数");
String year1=br.readLine();
float num1=Float.parseFloat(year1);
if(year1%4==0 &&year1%100!=0);{System.out.println("Leap year ");
else if(year1%400==0);{System.out.println("Leap year");
else{System.out.println("Common year");}
}
}各路高手看看我的Java编程,新手上路,请各位高手多多指教。或者告诉我怎么编判断闰年的程序。拜托了
------解决方案--------------------if(year1%4==0 &&year1%100!=0);{System.out.println("Leap year ");
else if(year1%400==0);{System.out.println("Leap year");
else{System.out.println("Common year");}
楼主思路正确!
------解决方案--------------------public static void main(String[] args){
System.out.print("input a year:");
Scanner s = new Scanner(System.in);
int year = s.nextInt();
if(year % 400 == 0
------解决方案--------------------
(year % 4 == 0 && year % 100 != 0))
System.out.println("Leap year");
else
System.out.println("Common year");
}