Advertisement
miroLLL

PipesInPool

Jan 23rd, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. import com.sun.org.apache.bcel.internal.classfile.SourceFile;
  2. import java.text.DecimalFormat;
  3. import java.util.Scanner;
  4.  
  5. /**
  6. * Created by LittleSucks on 21.1.2017 г..
  7. */
  8. public class PipesInThePool {
  9. public static void main(String[] args) {
  10.  
  11.  
  12. Scanner input = new Scanner(System.in);
  13. DecimalFormat remove = new DecimalFormat("0.##");
  14.  
  15. int v = Integer.parseInt(input.nextLine()); // Обем на басейна в литри
  16. int p1 = Integer.parseInt(input.nextLine()); // Дебит на първата тръба за час
  17. int p2 = Integer.parseInt(input.nextLine()); // Дебит на втората тръба за час
  18. double h = Double.parseDouble(input.nextLine()); // Часовете които работникът отсъства
  19.  
  20. p1 *= h;
  21. p2 *= h;
  22.  
  23. double twoPipes = p1 + p2;
  24.  
  25. if (twoPipes <= v) {
  26.  
  27. double p1Percent = (int)((p1 / twoPipes) * 100);
  28. double p2Percent = (int)((p2 / twoPipes) * 100);
  29. double poolPercent = (int)((twoPipes / v) * 100);
  30.  
  31. System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.", poolPercent, p1Percent, p2Percent);
  32.  
  33. } else {
  34.  
  35. double overflow = twoPipes - v;
  36. System.out.printf("For %s hours the pool overflows with %.0f liters.", remove.format(h), overflow);
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement