Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int v = Integer.parseInt(scan.nextLine());
- int p1 = Integer.parseInt(scan.nextLine());
- int p2 = Integer.parseInt(scan.nextLine());
- double h = Double.parseDouble(scan.nextLine());
- double v1 = (p1+p2) * h;
- double v1procent = Math.floor(v1/v * 100);
- double pp1 = Math.floor(p1 * h / v1 * 100);
- double pp2 = Math.floor(p2 * h / v1 * 100);
- if (v1 <= v) {
- System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.", v1procent, pp1, pp2);
- } else {
- DecimalFormat df = new DecimalFormat("0.##");
- System.out.printf("For %s hours the pool overflows with %.1f liters.", df.format(h), v1-v);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement