Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.String;
- public class ProverkiPoSlojni {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- int poolV = Integer.parseInt(console.nextLine());
- int pipe1 = Integer.parseInt(console.nextLine());
- int pipe2 = Integer.parseInt(console.nextLine());
- double timeH = Double.parseDouble(console.nextLine());
- double filledP1 = pipe1 * timeH;
- double filledP2 = pipe2 * timeH;
- if((filledP1 + filledP2) <= poolV){
- double totalPercent = Math.floor((filledP1 * 100 / poolV) + (filledP2 * 100 / poolV)) ;
- double percentP1 = Math.floor(filledP1 * 10 / totalPercent);
- double percentP2 = Math.floor(filledP2 * 10/ totalPercent);
- System.out.printf("The pool is %.0f%% full. Pipe 1: %.0f%%. Pipe 2: %.0f%%.", totalPercent, percentP1, percentP2);
- }else if((filledP1 + filledP2) > poolV){
- double overL =( filledP1 + filledP2 ) - poolV;
- System.out.printf("For %.1f hours the pool overflows with %.0f liters.", timeH, overL);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment