Hey guys,
I need some help again with this program I've been working on. Basically I'm trying to make it so that a user enters a year and then program prints if its a leap year or not.
Here is what I have so far:
// LeapYear.java
// Name
public class LeapYear
// Type in a year
// Print out whether year is leap year or not
{
import Java.util.Scanner;
public static void main( String[] args)
{
scanner scan = new Scanner(system.in);
System.out.println("Enter the year: " );
year = scan.nextInt();
// calculate whether or not year is a leap year
boolean leapyear = ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0));
if (isLeapYear)
{
println(year + " is a leap year.");
} else
println(year + " is not a leap year.");
}
}
Here are the errors when compiled:
LeapYear.java:10: illegal start of type
import Java.util.Scanner;
^
LeapYear.java:10: ';' expected
import Java.util.Scanner;
^
LeapYear.java:10: illegal start of type
import Java.util.Scanner;
^
LeapYear.java:10: ';' expected
import Java.util.Scanner;
^
LeapYear.java:10: <identifier> expected
import Java.util.Scanner;
Any help is appreciated!