Java Programming
Q1. WAP TO INPUT 2-DIGIT NUMBER AND CHECK IT IS SPECIAL OR NOT.A special two-digit number is such that when the sum of its digits is added to the product of its digits, the result is equal to the original two-digit number. Example: Consider the number 59. 5+9=14,5*9=45,45+14=59(DO NOT LOOP)
Answers
Answered by
3
Answer:
import java.util.*;
public class and
{
public static void main()
{
int n, z, i, s,c;
System.out.println("enter the two digit number");
n= in.nextInt();
z=(n%10);
i= ( n/10);
s= i+z
c= i *z
if ( c+s==n)
System.out.println(" special number");
else
System.out.println(" not a special number");
}
}
Answered by
1
import java.util.*;
class specialnumber
{
public void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter 2digit Number:");
int xy=sc.nextInt();
int x=xy/10;
int y=xy%10;
int sum=x+y;
int pro=x*y;
int res=sum+pro;
if (xy==res)
System.out.println("A Special Number");
else
System.out.println("Not a Special Number");
}
}
Similar questions