Advertisement
zigrek

Untitled

Jan 18th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 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 v = Integer.parseInt(scanner.nextLine());
  8. int p1 = Integer.parseInt(scanner.nextLine());
  9. int p2 = Integer.parseInt(scanner.nextLine());
  10. double h = Double.parseDouble(scanner.nextLine());
  11. double filled = p1*h + p2*h;
  12.  
  13. if (filled > v) {
  14. double overflow = filled - v;
  15. System.out.printf("For %.1f hours the pool overflows with %.1f liters.", h, overflow);
  16. } else {
  17. double percentall = Math.floor((filled/v)*100);
  18. double percentP1 = Math.floor(((p1*h)/filled)*100);
  19. double percentP2 = Math.floor(((p2*h)/filled)*100);
  20. System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.", percentall, percentP1, percentP2);
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement