Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.sun.org.apache.bcel.internal.classfile.SourceFile;
- import java.text.DecimalFormat;
- import java.util.Scanner;
- /**
- * Created by LittleSucks on 21.1.2017 г..
- */
- public class PipesInThePool {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- DecimalFormat remove = new DecimalFormat("0.##");
- int v = Integer.parseInt(input.nextLine()); // Обем на басейна в литри
- int p1 = Integer.parseInt(input.nextLine()); // Дебит на първата тръба за час
- int p2 = Integer.parseInt(input.nextLine()); // Дебит на втората тръба за час
- double h = Double.parseDouble(input.nextLine()); // Часовете които работникът отсъства
- p1 *= h;
- p2 *= h;
- double twoPipes = p1 + p2;
- if (twoPipes <= v) {
- double p1Percent = (int)((p1 / twoPipes) * 100);
- double p2Percent = (int)((p2 / twoPipes) * 100);
- double poolPercent = (int)((twoPipes / v) * 100);
- System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.", poolPercent, p1Percent, p2Percent);
- } else {
- double overflow = twoPipes - v;
- System.out.printf("For %s hours the pool overflows with %.0f liters.", remove.format(h), overflow);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement