Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //mirenna_i
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class testPipe {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- int volume = Integer.parseInt(console.nextLine());
- int debit1 = Integer.parseInt(console.nextLine());
- int debit2 = Integer.parseInt(console.nextLine());
- double hours = Double.parseDouble(console.nextLine());
- double pipe1Volume = hours * debit1;
- double pipe2Volume = hours * debit2;
- double fullVolume = pipe1Volume + pipe2Volume;
- DecimalFormat df = new DecimalFormat("0.##");
- if (volume >= fullVolume){
- double fullPercent = Math.floor(fullVolume / volume * 100);
- double pipe1Percent = Math.floor(pipe1Volume / fullVolume * 100);
- double pipe2Percent = Math.floor(pipe2Volume / fullVolume * 100);
- System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.\n", fullPercent, pipe1Percent, pipe2Percent);
- } else {
- double overVolume = fullVolume - volume;
- System.out.printf("For %s hours the pool overflows with %.1f liters.\n", df.format(hours), overVolume);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement