Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int volumePool = Integer.parseInt(scanner.nextLine());
- int pipe1 = Integer.parseInt(scanner.nextLine());
- int pipe2 = Integer.parseInt(scanner.nextLine());
- double hours = Double.parseDouble(scanner.nextLine());
- double pipe1Liters = pipe1 * hours;
- double pipe2Liters = pipe2 * hours;
- double pipesTotal = pipe1Liters + pipe2Liters;
- double percentage = (pipesTotal / volumePool) * 100;
- double pipe1Percentage = (pipe1Liters / pipesTotal) * 100;
- double pipe2Percentage = (pipe2Liters/ pipesTotal)* 100;
- String symbol = "%";
- if (percentage<100){
- System.out.printf("The pool is %.2f%s fool. Pipe 1: %.2f%s. Pipe 2: %.2f%s.", percentage,symbol, pipe1Percentage,symbol,pipe2Percentage,symbol);
- }else{
- double overflowsLiters = pipesTotal - volumePool;
- System.out.printf("For %.2f hours the pool overflows with %.2f liters.", hours,overflowsLiters);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement