Advertisement
veronikaaa86

07. World Swimming Record

Jun 13th, 2021
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double worldRecord = Double.parseDouble(scanner.nextLine());
  8. double distance = Double.parseDouble(scanner.nextLine());
  9. double timeForOneM = Double.parseDouble(scanner.nextLine());
  10.  
  11. double addingTimes = Math.floor(distance / 15);
  12. double resistance = addingTimes * 12.5;
  13.  
  14. double totalTimeIvan = (distance * timeForOneM) + resistance;
  15.  
  16. if (worldRecord <= totalTimeIvan) {
  17. System.out.printf("No, he failed! He was %.2f seconds slower.", totalTimeIvan - worldRecord);
  18. } else {
  19. System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", totalTimeIvan);
  20. }
  21. }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement