write a programs
to accept to a two- digit number and check whether it is a
special two digit number.
Answers
Answered by
1
Question:-
- Write a program to accept a two digit number and check whether it is a special two digit number or not.
Program:-
import java.util.*;
class Number
{
public static void main(String s[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a two digit number: ");
int a=sc.nextInt();
int x=a/10, y=a%10;
int r=(x+y)+(x*y)
if(r==a)
System.out.println("Number is a special two digit number.");
else
System.out.println("Number is not a special two digit number.");
}
}
Example:-
a=59
x=5 and y=9
x+y=14 and x*y=45
And, 14+45=59
So, 59 is a special two digit number.
Similar questions