Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int v = Integer.parseInt(scanner.nextLine());
- int p1 = Integer.parseInt(scanner.nextLine());
- int p2 = Integer.parseInt(scanner.nextLine());
- double h = Double.parseDouble(scanner.nextLine());
- double fillp1 = h * p1 ;
- double fillp2 = h * p2 ;
- double total = fillp1 + fillp2 ;
- if(total < v) {
- double proce = (total * 100) / v;
- double proP1 = (fillp1 * 100) / total ;
- double proP2 = (fillp2 * 100) / total;
- System.out.printf( "The pool is %.2f % full. Pipe1: %.2f %. Pipe2: %.2f %." , proce , proP1 , proP2 ) ;
- }
- else {
- double over = total - v ;
- System.out.printf( "For %.2f hours the pool overflows with %.2f liters" , h , over) ;
- }
- }
- }
Add Comment
Please, Sign In to add comment