Java program to print the two digits of the year

Java program to print the two digits of the year. A Java program to extract the year’s last two digits.As an input, you can use any integer. The last two digits of the provided integer are then extracted as output using modulus and division operations. The source code for the Java Program to Extract the Last Two Digits of a Year can be found here.

import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
int x, y, i = 0;
String z = "";
Scanner s = new Scanner(System.in);
System.out.print("Enter the year");
x = s.nextInt();
while(i < 2)
{
y = x % 10;
z = y + "" +z;
x = x / 10;
i++;
}
System.out.println("Last two digits"+z);
}
}

Enter the year 1980
Last two digits 80