Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Pool {
  5.  
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8. double vol = Double.parseDouble(scanner.nextLine());
  9. int p1 = Integer.parseInt(scanner.nextLine());
  10. int p2 = Integer.parseInt(scanner.nextLine());
  11. double hrs = Double.parseDouble(scanner.nextLine());
  12. double full = (p1 + p2)*hrs;
  13. double percent = (full/vol)*100;
  14. double perP1 = ((p1*hrs)/full)*100;
  15. double perP2 = ((p2*hrs)/full)*100;
  16. if (full <= vol ){
  17. System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.", Math.floor(percent), Math.floor(perP1), Math.floor(perP2));
  18. }
  19. else if (full> vol){
  20. Math.floor(full);
  21. vol = full - vol;
  22. System.out.printf("For %.1f hours the pool overflows with %.1f liters.",hrs, vol );
  23. }
  24.  
  25.  
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement