BubaLazi

Basein

Jan 30th, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.lang.String;
  3.  
  4. public class ProverkiPoSlojni {
  5.     public static void main(String[] args) {
  6.         Scanner console = new Scanner(System.in);
  7.  
  8.         int poolV = Integer.parseInt(console.nextLine());
  9.         int pipe1 = Integer.parseInt(console.nextLine());
  10.         int pipe2 = Integer.parseInt(console.nextLine());
  11.         double timeH = Double.parseDouble(console.nextLine());
  12.  
  13.         double filledP1 = pipe1 * timeH;
  14.         double filledP2 = pipe2 * timeH;
  15.  
  16.         if((filledP1 + filledP2) <= poolV){
  17.             double totalPercent = Math.floor((filledP1 * 100 / poolV) + (filledP2 * 100 / poolV)) ;
  18.             double percentP1 = Math.floor(filledP1 * 10 / totalPercent);
  19.             double percentP2 = Math.floor(filledP2 * 10/ totalPercent);
  20.             System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.", totalPercent, percentP1, percentP2);
  21.         }else if((filledP1 + filledP2) > poolV){
  22.             double overL =( filledP1 + filledP2 ) - poolV;
  23.             System.out.printf("For %.1f hours the pool overflows with %.0f liters.", timeH, overL);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment