Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gg;
- import java.util.Scanner;
- public class PipesInPool {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int vPool = Integer.parseInt(scanner.nextLine());
- int tube1 = Integer.parseInt(scanner.nextLine());
- int tube2 = Integer.parseInt(scanner.nextLine());
- double hours = Double.parseDouble(scanner.nextLine());
- double pipe1 = tube1 * hours;
- double pipe2 = tube2 * hours;
- double fullDebit = pipe1 + pipe2;
- double poolPercent = (fullDebit / 1000) * 100;
- double pipe1Percent = (pipe1 / fullDebit) * 100;
- double pipe2Percent = (pipe2 / fullDebit) * 100;
- if (fullDebit > vPool){
- System.out.printf("For %.2f hours the pool overflows with %.2f liters.", hours, fullDebit - vPool);
- }else {
- System.out.printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.", poolPercent, pipe1Percent, pipe2Percent);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement