Advertisement
-and_

Untitled

Mar 31st, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.       Scanner scanner = new Scanner(System.in);
  6.         int v = Integer.parseInt(scanner.nextLine());
  7.         int p1 = Integer.parseInt(scanner.nextLine());
  8.         int p2 = Integer.parseInt(scanner.nextLine());
  9.         double h = Double.parseDouble(scanner.nextLine());
  10.         double fillp1 = h * p1 ;
  11.         double fillp2 = h * p2 ;
  12.         double total = fillp1 + fillp2 ;
  13.         if(total < v) {
  14.            double proce = (total * 100) / v;
  15.             double proP1 = (fillp1 * 100) / total ;
  16.             double proP2 = (fillp2 * 100) / total;
  17.             System.out.printf( "The pool is %.2f % full. Pipe1: %.2f %. Pipe2: %.2f %." , proce , proP1 , proP2 ) ;
  18.         }
  19.         else {
  20.             double over = total - v ;
  21.             System.out.printf( "For %.2f hours the pool overflows with %.2f liters" , h , over) ;
  22.         }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement