How would you get it to ask you to input Y or N? I have been working on this for a few days now. I am new to Java coding and I am taking AP Computer Science Principles. Thanks for the Help and if you could leave any tips about how I could improve that would be very helpful and appreciated.
import java.util.Scanner;
public class Project_3_3 {
public static void main(String[] args)
{
int year;
boolean leap = false, num1;
String answer = "y";
Scanner Scan = new Scanner(System.in);
while (answer.equals("y"))
{
System.out.println("Enter in a year greater or equal to 1582 ");
year = Scan.nextInt();
if (year>1582) {
if ((year % 400==0 && year %100 !=0) || (year % 4 ==0 && year %
`enter code here`400==0)
|| year %4 ==0 && year % 100 !=0)
System.out.println(year + " is a leap year");
else
System.out.println(year + " is not a leap year");
System.out.println();
System.out.println("Test another year Y/N");
answer = Scan.nextLine();
}
}
}