Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ThreeBrothers {
- public static void main(String[] agrs) {
- Scanner scanner = new Scanner(System.in);
- double firstTime = Double.parseDouble(scanner.nextLine());
- double secondTime = Double.parseDouble(scanner.nextLine());
- double thirdTime = Double.parseDouble(scanner.nextLine());
- double fatherTime = Double.parseDouble(scanner.nextLine());
- double totalTime = 1 / (1 / firstTime + 1 / secondTime + 1 / thirdTime);
- double timeWithRest = (0.15 * totalTime) + totalTime; //1.15 * totalTime
- double diff = fatherTime - timeWithRest; //8 - 6 = 2
- System.out.printf("Cleaning time: %.2f%n",timeWithRest);
- if(diff > 0){
- System.out.printf("Yes, there is a surprise - time left -> %d hours.",(int)(Math.floor(diff)));
- }else {
- diff = Math.abs(diff);// -2 -> 2
- System.out.printf("No, there isn't a surprise - shortage of time -> %d hours.", (int)(Math.ceil(diff)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement