World Swimming Recor Java.
При въвеждане на вторите примерни стойности на променливите резултата е напълно различен от очаквания.
Проблем с въвеждане на първите няма.
Къде е проблема?
Благодаря!
import java.util.Scanner; public class WorldSwimmingRecord { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double worldRecord = Double.parseDouble(sc.nextLine()); double meters = Double.parseDouble(sc.nextLine()); double timeInSecsFor1meter = Double.parseDouble(sc.nextLine()); double swimmingDistance = meters * timeInSecsFor1meter; double additionalTime = meters / 15 * ( 12.5 ); double totalTime = swimmingDistance + additionalTime; double timeLeft = totalTime - worldRecord; if (worldRecord < totalTime) { timeLeft = totalTime - worldRecord; System.out.printf("No, he failed! He was %.2f seconds slower.", timeLeft); }else{ System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", timeLeft); } } }