Advertisement
gowtham900

threebox

Oct 7th, 2021
647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1.  
  2. import java.util.*;
  3. import java.lang.*;
  4. import java.io.*;
  5.  
  6. /* Name of the class has to be "Main" only if the class is public. */
  7. class Codechef
  8. {
  9.     public static void main (String[] args)
  10.     {
  11.  
  12.         Scanner input=new Scanner(System.in);
  13.         int t=input.nextInt();
  14.         while(t>0) {
  15.             int box1 = input.nextInt();
  16.             int box2 = input.nextInt();
  17.             int box3 = input.nextInt();
  18.             int total_size = input.nextInt();
  19.             BoxSize(box1, box2, box3, total_size);
  20.             t--;
  21.         }
  22.  
  23.     }
  24.     public static void BoxSize(int box1, int box2, int box3, int total_size){
  25.        int sum=box1+ box2+box3;
  26.        if (sum==total_size){
  27.            System.out.println(1);
  28.        }
  29.        else if (sum>=box3+box2||sum>=box2+box1){
  30.            System.out.println(2);
  31.        }
  32.        else{
  33.            System.out.println(3);
  34.        }
  35.  
  36.  
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement