Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
// Leapyear.java
//
// Calculates leap years using simple math and nested if-statements
//*******************************************************************
import java.util.Scanner; // imports the class Scanner from the Utilities Library
System.out.println (" Enter the date of year that is after 1581 (0 to quit): ");
inputyear = scan.nextInt(); // Allows the user to input
while (inputyear != 0)
{
if (inputyear < 1582) // Sets so if the value zero is inputted, the system ends.
{ // The while loop that if the value zero is inputted the program doesnt work and
it results in an error
System.out.println (" Invalid (The Gregorian calendar was adopted on 1582):
"); // Prints out the statement in quotation
System.out.println();
System.out.println (" Enter the date of year that is after 1581 (0 to quit): ");
}
}
}
System.out.println("Program has terminated.");
}
}