Advertisement
desislava_topuzakova

Untitled

Feb 2nd, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.text.DecimalFormat;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7. public static void main(String[] args) {
  8. Scanner scan = new Scanner(System.in);
  9.  
  10. int v = Integer.parseInt(scan.nextLine());
  11. int p1 = Integer.parseInt(scan.nextLine());
  12. int p2 = Integer.parseInt(scan.nextLine());
  13. double h = Double.parseDouble(scan.nextLine());
  14.  
  15. double v1 = (p1+p2) * h;
  16. double v1procent = Math.floor(v1/v * 100);
  17. double pp1 = Math.floor(p1 * h / v1 * 100);
  18. double pp2 = Math.floor(p2 * h / v1 * 100);
  19.  
  20.  
  21. if (v1 <= v) {
  22. System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.", v1procent, pp1, pp2);
  23. } else {
  24. DecimalFormat df = new DecimalFormat("0.##");
  25. System.out.printf("For %s hours the pool overflows with %.1f liters.", df.format(h), v1-v);
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement