Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. package pipesinpool;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class PipesInPool {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int volume = Integer.parseInt(scanner.nextLine());
  10.         int Pipe1 = Integer.parseInt(scanner.nextLine());
  11.         int Pipe2 = Integer.parseInt(scanner.nextLine());
  12.         double HP = Double.parseDouble(scanner.nextLine());
  13.  
  14.        
  15.         double liters = (Pipe1 + Pipe2)*HP;
  16.         int volumeP = (int)((liters / volume) * 100);
  17.         int Pipe11 = (int)((Pipe1 * HP)/liters*100);
  18.         int Pipe22 = (int)((Pipe2 * HP)/liters*100);
  19.        
  20.         double liters1 = ((Pipe1+Pipe2)*HP - volume);
  21.  
  22.         if (liters <= volume){
  23.             System.out.printf("The pool is %d full. 1: %d. 2: %d.",
  24.                     volumeP,Pipe11,Pipe22);
  25.         }else {
  26.             System.out.printf("For %.1f hours the pool overflows with %.0f liters.", HP, liters1);
  27.         }
  28.  
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement