Advertisement
galinyotsev123

ProgBasicsJavaBook3.2SimpleConditions02PipesInPool

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