As you can see, the input data types are integer (if the user enters a year) and string (if the user enters 'exit') respectively.
import java.util.Scanner; public class LeapYear { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("This program can determine whether a year is a leap year or not."); System.out.println("You may repeat this program as long as you want, otherwise enter 'exit'."); int y, rem4, rem100, rem400; String cont = "yadda"; while(cont != "exit" || cont != "Exit" || cont != "EXIT") { System.out.print("Enter a year: "); y = input.nextInt(); cont = input.nextLine(); rem4 = y % 4; rem100 = y % 100; rem400 = y % 400; if (rem4 == 0 || rem400 == 0 && rem100 != 0) System.out.println("This year is a leap year."); else System.out.println("This year is not a leap year."); } } }
The code works flawless... except that when I want to exit the program, it does so in an Exception
What have I done wrong? Pls help *cute puppy face*