velikova_olya

pipes

Jan 25th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. package SimpleCondStateExams;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Pipes {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. // int volumePool = Integer.parseInt(scanner.nextLine());
  10. // int debitPipe1For1Hour = Integer.parseInt(scanner.nextLine());
  11. // int debitPipe2For1Hour = Integer.parseInt(scanner.nextLine());
  12.  
  13. double volumePool = Double.parseDouble(scanner.nextLine());
  14. double debitPipe1For1Hour = Double.parseDouble(scanner.nextLine());
  15. double debitPipe2For1Hour = Double.parseDouble(scanner.nextLine());
  16. double hoursWorkerIsMissing = Double.parseDouble(scanner.nextLine());
  17.  
  18. double pipe1TotalHours = debitPipe1For1Hour * hoursWorkerIsMissing;
  19. double pipe2TotalHours = debitPipe2For1Hour * hoursWorkerIsMissing;
  20. double pipesTotalVolume = pipe1TotalHours + pipe2TotalHours;
  21. double overflow = pipesTotalVolume - volumePool;
  22.  
  23. if (volumePool >= pipesTotalVolume) {
  24. System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.",
  25. Math.floor(pipesTotalVolume / volumePool * 100),
  26. Math.floor(pipe1TotalHours / pipesTotalVolume * 100),
  27. Math.floor(pipe2TotalHours / pipesTotalVolume * 100));
  28. } else {
  29. System.out.printf("For %.1f hours the pool overflows with %.1f liters.", hoursWorkerIsMissing, overflow);
  30. // System.out.println("For " + hoursWorkerIsMissing + " hours the pool overflows with " + overflow + " liters.");
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment