A leap year is a year with 366 days.A leap year has the 29th February.A year is a leap year if it is divisible by 4 except forthe century years (divisible by 100).Century years are only leap years if they are divisible by 400.Write a program thatacce
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/26 21:52:52
A leap year is a year with 366 days.A leap year has the 29th February.A year is a leap year if it is divisible by 4 except forthe century years (divisible by 100).Century years are only leap years if they are divisible by 400.Write a program thatacce
A leap year is a year with 366 days.A leap year has the 29th February.A year is a leap year if it is divisible by 4 except for
the century years (divisible by 100).Century years are only leap years if they are divisible by 400.Write a program that
accepts a year and determines if it is a leap year.
\x05\x05\x05\x05
\x05\x05\x05
\x05\x05\x05
\x05\x05\x05\x05
\x05\x05\x05\x05\x05
Use a separate method to test if a year is a leap year.
my answer:
import java.util.Scanner;
public class JavaApplication24 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.print("Enter a year:");
int a=input.nextInt();
if((a is divisible by 4 || a is divisible by 400)){
System.out.println("a");
}else {
System.out.println("a is not a leap year");
}}
}
运行不出来?
A leap year is a year with 366 days.A leap year has the 29th February.A year is a leap year if it is divisible by 4 except forthe century years (divisible by 100).Century years are only leap years if they are divisible by 400.Write a program thatacce
a is divisible by 4 || a is divisible by 400)
改成
a%4==0 || a %400==0