import java.util.Scanner; public class Pipes { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // правим скенер int V = scanner.nextInt(); // V заема стойността от първия ред вкаран в конзолата, който трябва да бъде Int int P1 = scanner.nextInt(); // P1 заема стойността от втория ред вкаран в конзолата, който трябва да бъде Int int P2 = scanner.nextInt(); // P2 заема стойността от третия ред вкаран в конзолата, който трябва да бъде Int float H = scanner.nextFloat(); // H заема стойността от четвъртия ред вкаран в конзолата, който трябва да бъде Float if (Pool_condition(V,P1,P2,H)!=0) { // ако стойността на метода е различна от нула да принтира дадените по условия неща, използваме %% защото % е специален символ System.out.printf("The pool is %d%% full. Pipe 1: %d%%. Pipe2: %.2f%% .", Pool_condition(V, P1, P2, H), Pipe1Percentage(P1, P2, H), Pipe2Percentage(P1, P2, H)); } else{// ако е стойността на метода е 0 принтираме с колко литра е прелял басейна System.out.printf("For H hours the pool overflows with %.2f liters.", (P1+P2)*H - V); } } public static Integer Pool_condition(int volume, int pipe1, int pipe2, float hours){ // метод който очаква като параметри int volume, int pipe1, int pipe2, float hours. Той връща колко е пълен басейна като Integer float last_volume =(float) (pipe1 + pipe2) * hours; // смятаме колко литра вземат тръбите if (last_volume < volume) { // проверяваме дали източената вода е по-малко от цялата return (int)(last_volume / volume) * 100; } else{ // ако е повече или равна връщаме 0 като стойност return 0; } } public static Integer Pipe1Percentage(int pipe1, int pipe2, float hours){// Метод, приема 3 стойности: int pipe1, int pipe2, float hours и пресмята процентите на първата тръба float debit_total = (pipe1 + pipe2) * hours; float percentage = (pipe1*hours / debit_total) * 100; return (int)percentage; } public static Integer Pipe2Percentage(int pipe1, int pipe2, float hours){// Метод, приема 3 стойности: int pipe1, int pipe2, float hours и пресмята процентите на втората тръба float debit_total = (pipe1 + pipe2) * hours; float percentage = (pipe2*hours / debit_total) * 100; return (int)percentage; } }