Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PrintF {
  4.  
  5. public static void main(String[] args) {
  6. Scanner scan = new Scanner(System.in);
  7.  
  8. int poolSizeLitres = Integer.parseInt(scan.nextLine());
  9. int tubeOneDebitPerHour = Integer.parseInt(scan.nextLine());
  10. int tubeTwoDebitPerHour = Integer.parseInt(scan.nextLine());
  11. double breakTimePerHour = Double.parseDouble(scan.nextLine());
  12.  
  13. double tubeOneInput = tubeOneDebitPerHour * breakTimePerHour;
  14. double tubeOTwoInput = tubeTwoDebitPerHour * breakTimePerHour;
  15. double bothTubesInput = tubeOneInput + tubeOTwoInput;
  16.  
  17. double percentageTubeOne = (tubeOneInput / bothTubesInput) * 100;
  18. double percentageTubeTwo = (tubeOTwoInput / bothTubesInput) * 100;
  19. double howFullIsPool = (bothTubesInput / poolSizeLitres) * 100;
  20.  
  21. if (bothTubesInput <= poolSizeLitres) {
  22. System.out.printf("The pool is %.2f%% full. Pipe 1: %.2f. Pipe 2: %.2f%%.", howFullIsPool, percentageTubeOne, percentageTubeTwo);
  23.  
  24. } else if (bothTubesInput > poolSizeLitres) {
  25. howFullIsPool = howFullIsPool - poolSizeLitres;
  26. System.out.printf("For %.2f hours the pool overflows with %.2f liters.", breakTimePerHour, howFullIsPool);
  27. }
  28.  
  29.  
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement