Page 56 - CTS - CSA TP - Volume 2
P. 56
COMPUTER SOFTWARE APPLICATION - CITS
• It prompts the user to enter a year by displaying the message “Enter a year: “.
• It reads the integer input provided by the user using the nextInt() method of the Scanner class and stores it
in the variable year.
4 The program then checks whether the entered year is divisible by 100 without leaving a remainder:
• If the remainder of year divided by 100 is equal to 0, then the year is a century year.
• If the remainder is not equal to 0, then the year is not a century year.
5 Depending on the result of the check, the program prints out a message indicating whether the year is a century
year or not.
6 Finally, the scanner object is closed to release system resources after it’s no longer needed.
Output:
41
CITS : IT & ITES - Computer Software Application - Exercise 85 CITS : IT & ITES - Computer Software Application - Exercise 85