I need to write a method for a leap year. So the method has to be called printleap and checks to see if the number is a leap year or not. So the the java program will test the method by reading a list of year number and only displays the leap years. Here is what I have done:
import java.util.Scanner; public class Ex1PartAassig3 {
public static int printleap(String string) {
Scanner sc1=new Scanner(System.in);
{
System.out.println("This programe calculates leap year.");
int year= printleap ("Enter the year:");
if ((year%4==0)&& year % 100 !=0)
}
System.out.println(year + "is a leap year.");
{
else if ((year % 4==0) && (year % 100==0)&&(year % 400==0))
{
System.out.println(year +"is a leap year.");
}
else {
}
System.out.println(year + " is not a leap year.");
}
}
}
The areas that are showing a mistake are underline the first 'else' else if ((year % 4==0) && (year % 100==0)&&(year % 400==0)
and two curly brackets, the first just above the second system.out and the 1st bracket at the very bottom.There is 3 brackets on the bottom but its the first 1.
Could some help me to run this program or what I have forgotten thank you?