Advertisement
porteno

y_q3

Dec 7th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Q3 {
  4.  
  5. public static void main(String[] args) {
  6. int sum = 0;
  7. Scanner in = new Scanner(System.in);
  8. System.out.println("enter first number(3 digits long):");
  9. int num1 = in.nextInt();
  10. System.out.println("enter second number(3 digits long):");
  11. int num2 = in.nextInt();
  12. sum = Math.abs(num1%10 - num2%10)+
  13. Math.abs(num1%100/10 - num2%100/10) + Math.abs(num1/100 - num2/100);
  14. System.out.println(sum);
  15.  
  16. }
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement