Advertisement
uktcar

09.1.02FromLeftToTheRightt

Apr 3rd, 2023
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Pr02FromLeftToTheRight {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         int n = Integer.parseInt(scanner.nextLine());
  9.  
  10.         for (int i = 1; i <= n; i++) {
  11.             double num1 = Double.parseDouble(scanner.next());
  12.             double num2 = Double.parseDouble(scanner.next());
  13.  
  14.             int digitsSum = 0;
  15.             double maxNumber = Math.abs(Math.max(num1, num2));
  16.  
  17.             while (maxNumber > 0) {
  18.                 digitsSum += (maxNumber % 10);
  19.                 maxNumber /= 10;
  20.             }
  21.  
  22.             System.out.println(digitsSum);
  23.         }
  24.  
  25.     }
  26. }
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement