Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package classwork;
- import java.util.Scanner;
- public class Trubi {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int volume = Integer.parseInt(scan.nextLine());
- int pipe1 = Integer.parseInt(scan.nextLine());
- int pipe2 = Integer.parseInt(scan.nextLine());
- double hours = Double.parseDouble(scan.nextLine());
- double pipe1_w = pipe1 * hours;
- double pipe2_w = pipe2 * hours;
- double water = (pipe1_w + pipe2_w);
- if(water <= volume) {
- System.out.printf("The pool is %.0f %% full.Pipe_1: %.0f%%. Pipe_2: %.0f%%." ,
- Math.floor( (water / volume) * 100),
- Math.floor((pipe1_w ) / water * 100),
- Math.floor((pipe2_w) / water * 100)
- );
- }else {
- System.out.printf("For %.0f hours the pool overflows with %.0f litters" , hours,(water - volume));
- }
- scan.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement