Sentient loop not running [closed]
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 15 hours ago.
Improve this questionAnyone know why my loop isn't running?
import java.util.*;
import java.io.*;
public class LeapYear {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
String start = "y";
while (start.equals("y"));
{
System.out.println("Enter a year");
int year = input.nextInt();
if(year < 1582)
{
System.out.println("please enter another year");
year = input.nextInt();
}
if(year % 4 == 0 && year%100 != 0 )
{
System.out.println(year + " is a leap year");
}
else if (year % 400 == 0)
System.out.println(year + " is a leap year");
else
System.out.println(year+" is not a leap year");
System.out.println("Continue? y/n");
开发者_Python百科 start = input.next();
}
}
}
Supposed to check if a year is a leap year but it won't even run the loop I have no idea what the problem is. I tried switching it to a do while loop but that didn't solve it either
精彩评论