When I try to compile this, I keep getting an error that says \"cannot find symb
ID: 3650744 • Letter: W
Question
When I try to compile this, I keep getting an error that says "cannot find symbol - variable System" and I googled the problem and 95% of people who have that problem just didn't put "import java.util.Scanner" at the top, but I did that and am still having problems. I'm sure it's something simple, but i just can't figure it out./**
* A programs that will take in an imput of a year and give an output telling you whether or not it is a leap year
*
* @author
* @version 1.0
*/
import java.util.Scanner;
public class LeapYear
{
public static void main (String[] args)
{
//The input of the year to be calculated
Scanner leap = new Scanner(Sytstem.in);
int theYear;
System.out.print("Enter the year you wish to calculate: ");
theYear = leap.nextInt();
//If the year is divisable by 4, it is a leap year
if (theYear % 4 == 0) {
//If it is divisible by for, but also by 100, it is not a leap year
if (theYear % 100 != 0) {
System.out.println(theYear + " is a leap year.");
}
//If the year is divisible by 4, 100, and 400, it is a leap year
else if (theYear % 400 == 0) {
System.out.println(theYear + " is a leap year.");
}
//If the year is divisible by 4, and 100, but is not by 400, it is not a leap year
else {
System.out.println(theYear + " is not a leap year.");
}
}
//If it is not divisible by 4, it is not a leap year
else {
System.out.println(theYear + " is not a leap year.");
}
}
}
Explanation / Answer
please rate - thanks
you spelled System wrong in the Scanner declaration
/**
* A programs that will take in an imput of a year and give an output telling you whether or not it is a leap year
*
* @author
* @version 1.0
*/
import java.util.Scanner;
public class LeapYear
{
public static void main (String[] args)
{
//The input of the year to be calculated
Scanner leap = new Scanner(System.in);
int theYear;
System.out.print("Enter the year you wish to calculate: ");
theYear = leap.nextInt();
//If the year is divisable by 4, it is a leap year
if (theYear % 4 == 0) {
//If it is divisible by for, but also by 100, it is not a leap year
if (theYear % 100 != 0) {
System.out.println(theYear + " is a leap year.");
}
//If the year is divisible by 4, 100, and 400, it is a leap year
else if (theYear % 400 == 0) {
System.out.println(theYear + " is a leap year.");
}
//If the year is divisible by 4, and 100, but is not by 400, it is not a leap year
else {
System.out.println(theYear + " is not a leap year.");
}
}
//If it is not divisible by 4, it is not a leap year
else {
System.out.println(theYear + " is not a leap year.");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.