Advertisement
mswi12

Untitled

Oct 27th, 2017
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.24 KB | None | 0 0
  1. //mirenna_i
  2. import java.text.DecimalFormat;
  3. import java.util.Scanner;
  4. public class testPipe {
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner console = new Scanner(System.in);
  8.         int volume = Integer.parseInt(console.nextLine());
  9.         int debit1 = Integer.parseInt(console.nextLine());
  10.         int debit2 = Integer.parseInt(console.nextLine());
  11.         double hours = Double.parseDouble(console.nextLine());
  12.         double pipe1Volume = hours * debit1;
  13.         double pipe2Volume = hours * debit2;
  14.         double fullVolume = pipe1Volume + pipe2Volume;
  15.         DecimalFormat df = new DecimalFormat("0.##");
  16.  
  17.         if (volume >= fullVolume){
  18.             double fullPercent = Math.floor(fullVolume / volume * 100);
  19.             double pipe1Percent = Math.floor(pipe1Volume / fullVolume * 100);
  20.             double pipe2Percent = Math.floor(pipe2Volume / fullVolume * 100);
  21.  
  22.             System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.\n", fullPercent, pipe1Percent, pipe2Percent);
  23.         } else {
  24.             double overVolume = fullVolume - volume;
  25.  
  26.             System.out.printf("For %s hours the pool overflows with %.1f liters.\n", df.format(hours), overVolume);
  27.         }
  28.  
  29.     }
  30.  
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement