Advertisement
myrdok123

P06WorldSwimmingRecord_Second

Jan 15th, 2023
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. package L2ConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06WorldSwimmingRecord {
  6.  
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9.  
  10.  
  11. //Прочитаме от конзолата
  12. //Пресмятаме забавянето
  13. //Резултата, за който Иван преплува разстоянието -> разстоянието * времето за 1м + забавянето
  14. //Правим проверка дали е подобрил рекордът
  15.  
  16. double recordInSeconds = Double.parseDouble(scanner.nextLine());
  17. double distance = Double.parseDouble(scanner.nextLine());
  18. double timeForOneMeter = Double.parseDouble(scanner.nextLine());
  19.  
  20. double delay = (Math.floor(distance / 15)) * 12.5;
  21.  
  22. double result = distance * timeForOneMeter + delay;
  23.  
  24. if(recordInSeconds > result){
  25. System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", result);
  26. }else {
  27. double neededSeconds = result - recordInSeconds;
  28. System.out.printf("No, he failed! He was %.2f seconds slower.", neededSeconds);
  29. }
  30. }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement