Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.         int volumePool = Integer.parseInt(scanner.nextLine());
  10.         int pipe1 = Integer.parseInt(scanner.nextLine());
  11.         int pipe2 = Integer.parseInt(scanner.nextLine());
  12.         double hours = Double.parseDouble(scanner.nextLine());
  13.         double pipe1Liters = pipe1 * hours;
  14.         double pipe2Liters = pipe2 * hours;
  15.         double pipesTotal = pipe1Liters + pipe2Liters;
  16.         double percentage = (pipesTotal / volumePool) * 100;
  17.         double pipe1Percentage = (pipe1Liters / pipesTotal) * 100;
  18.         double pipe2Percentage = (pipe2Liters/ pipesTotal)* 100;
  19.         String symbol = "%";
  20.         if (percentage<100){
  21.             System.out.printf("The pool is %.2f%s fool. Pipe 1: %.2f%s. Pipe 2: %.2f%s.", percentage,symbol, pipe1Percentage,symbol,pipe2Percentage,symbol);
  22.         }else{
  23.             double overflowsLiters = pipesTotal - volumePool;
  24.             System.out.printf("For %.2f hours the pool overflows with %.2f liters.", hours,overflowsLiters);
  25.         }
  26.  
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement