Code is copied!
Program To Print Jupiter Number JAVA
Write a Program to print whether the inputted number is Jupiter or not.
[A number is said to be jupiter number if it is completely divisible by sum of its first and last digit. Example : 126 ]
import java.util.*;
class jupiter
{
public static void main(String args[])
{
Scanner sc = new Scanner (System.in);
int n = sc.nextInt();
int rev=0, sum = 0, temp =n;
int lastdigit= n%10;
while (n>0)
{
int digit = n % 10;
rev = rev * 10 + digit;
n=n/10;
}
int firstdigit = rev % 10;
sum = lastdigit + firstdigit;
if(temp % sum == 0)
{
System.out.println("yes it is jupiter number");
}
else
{
System.out.println("No it is not jupiter");
}
}
}