Java program to increment by 1 all the digits of a given integer

Java program to increment by 1 all the digits of a given integer. This is a Java program that increments all of a given integer’s digits by one. As input, you may use any integer. Following that, we extract each digit and increment it by one using various operations such as modulus and division. The Java Program to Increment All the Digits of a given Integer by 1 source code is available here.

import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
int n, m = 0, a;
Scanner s = new Scanner(System.in);
System.out.print("Enter any number:");
n = s.nextInt();
while(n > 0)
{
a = n % 10;
a++;
m = m * 10 + a;
n = n / 10;
}
n = m;
m = 0;
while(n > 0)
{
a = n % 10;
m = m * 10 + a;
n = n / 10;
}
System.out.println("Output"+m);
}
}

Enter any number: 45

Output 56