+ Нов въпрос
Tarantula83 3 Точки

## Задача Three Brothers Помощ!

Здравейте колеги! Може ли малко помощ че вече блокирах от всякаде!Къде бъркам?

Ето го и кода ми:

```import java.util.Scanner;

public class ThreeBrothers {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

double firstBrother = Double.parseDouble(scanner.nextLine());
double secondBrother = Double.parseDouble(scanner.nextLine());
double thirdBrother = Double.parseDouble(scanner.nextLine());
double father = Double.parseDouble(scanner.nextLine());

double totalTime = 1 / (1 / firstBrother + 1 / secondBrother + 1 / thirdBrother);
double timeWhitRest = totalTime * 0.15;
totalTime += timeWhitRest;
double timeRemaining = father - totalTime;

System.out.print("Clearing time: ");
System.out.printf("%.0f",Math.floor(totalTime));
if (timeRemaining > 0) {
timeRemaining = Math.floor(timeRemaining);
System.out.println("Yes, there is a surprise - time left -> {Math.Abs(Math.Ceiling( timeRemaining))} hours.");

}else {
System.out.printf("No, there isn't a surprise - shortage of time -> {Math.Abs(Math.Floor(timeRemaining))} hours.");
}
System.out.println(timeRemaining);
}
}```

Благодаря предварително!

Тагове:
0
VasilK 39 Точки

Привет,

Объркано е условието. За да добавиш 15% трябва да умнижиш по 1.15 не по 0.15.

import java.util.Scanner;

public class W2_E6_Three_Brothers {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

double bro_1 = Double.parseDouble(scanner.nextLine());
double bro_2 = Double.parseDouble(scanner.nextLine());
double bro_3 = Double.parseDouble(scanner.nextLine());
double fishTime = Double.parseDouble(scanner.nextLine());

double totTime = 1 / (1 / bro_1 + 1 / bro_2 + 1 / bro_3);
totTime = totTime * 1.15;

if (totTime < fishTime) {
System.out.printf("Cleaning time: %.2f%n", totTime);
System.out.printf("Yes, there is a surprise - time left -> %.0f hours.", Math.abs(Math.floor(fishTime - totTime)));
} else {
System.out.printf("Cleaning time: %.2f%n", totTime);
System.out.printf("No, there isn't a surprise - shortage of time -> %.0f hours.", Math.abs(Math.floor(fishTime - totTime)));
}

}
}

0
Tarantula83 3 Точки

Мерси човек скъса ми нервите направо тая задача!

0
Edzhevit 77 Точки

Просто трябва да добавиш totalTime + (totaltime * 0.15) всичко друго е точно.

https://pastebin.com/BzfWkVh6

0