开发者

Sentient loop not running [closed]

开发者 https://www.devze.com 2022-12-07 23:32 出处:网络
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.

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 question

Anyone 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

0

精彩评论

暂无评论...
验证码 换一张
取 消