Advertisement
MilaDimitrovaa

trubi

Nov 4th, 2019
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. package classwork;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Trubi {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.        
  10.         int volume = Integer.parseInt(scan.nextLine());
  11.         int pipe1 = Integer.parseInt(scan.nextLine());
  12.         int pipe2 = Integer.parseInt(scan.nextLine());
  13.        
  14.         double hours = Double.parseDouble(scan.nextLine());
  15.         double pipe1_w = pipe1 * hours;
  16.         double pipe2_w = pipe2 * hours;
  17.         double water = (pipe1_w + pipe2_w);
  18.        
  19.         if(water <= volume) {
  20.            
  21.             System.out.printf("The pool is %.0f %% full.Pipe_1: %.0f%%. Pipe_2: %.0f%%." ,
  22.                     Math.floor( (water / volume) * 100),
  23.                     Math.floor((pipe1_w ) / water * 100),
  24.                     Math.floor((pipe2_w) / water * 100)
  25.                    
  26.                     );
  27.            
  28.         }else {
  29.             System.out.printf("For %.0f hours the pool overflows with %.0f litters" , hours,(water - volume));
  30.            
  31.         }
  32.        
  33.     scan.close();
  34.     }
  35.      
  36.    
  37.  
  38.                    
  39.  
  40.            
  41.            
  42.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement