32. JAVA Program to Check Middle digit of given 3 digit number is Equal to the Sum of Other Two digits or Not.
How does this program work?
- This Program is used to Check Middle digit of given 3 digit number is Equal to the Sum of Other Two digits or Not
Here is the code
//Check middle digit of given number
import java.util.Scanner;public class Digit
{
public static void main(String[] args)
{
int number,l,f,m,s;
System.out.print("Enter Numbers :\n");
Scanner sc=new Scanner(System.in);
number = sc.nextInt();
l=number%10;
f=number/100;
m=(number/10)%10;
s=l+f;
if(s==m)
{
System.out.println("sum of number equal to middle number");
}
else
{
System.out.println("sum of number not equal to middle number");
}
}
}