Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Q3 {
- public static void main(String[] args) {
- int sum = 0;
- Scanner in = new Scanner(System.in);
- System.out.println("enter first number(3 digits long):");
- int num1 = in.nextInt();
- System.out.println("enter second number(3 digits long):");
- int num2 = in.nextInt();
- sum = Math.abs(num1%10 - num2%10)+
- Math.abs(num1%100/10 - num2%100/10) + Math.abs(num1/100 - num2/100);
- System.out.println(sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement