write a program to input a number and display the new number of the reversing the digits of the original number. the program also displays the absolute difference between original number and the reversed number.
sample input : 194
Sample output : 491
Absolute difference : 297
write the program using either inputstreamreader or scanner classes
Answers
Answered by
28
Hope its helpful!!!!
Attachments:
justauser2:
correct r u sure??
Answered by
31
Answer:
example;
if we take a number like 194
then its reversed digits are 491 and its absolute difference is (194-491)=-297 which is 297 avoid the symbols.
Explanation:
import java.util.*;
class tenth
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int n,r=0,a,b;
System.out.println("Enter the number to find its reverse number and absolute difference");
n=sc.nextInt();
while(n != 0)
{
int d=n%10;
r =r*10+d;
n/=10;
}
a=Math.abs(n-r);
System.out.println("The reversed number="+r);
System.out.println("The Absolute difference="+a);
}
}
Similar questions
Math,
7 months ago
Math,
7 months ago
Political Science,
7 months ago
Chemistry,
1 year ago
English,
1 year ago