Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
83
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 %.2f hours the pool overflows with %.2f 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