Advertisement
Spocoman

06. World Swimming Record

Aug 24th, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class WorldSwimmingRecord {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double record = Double.parseDouble(scanner.nextLine());
  7.         double distance = Double.parseDouble(scanner.nextLine());
  8.         double secondsToMeter = Double.parseDouble(scanner.nextLine());
  9.  
  10.         double score = distance * secondsToMeter + Math.floor(distance / 15) * 12.5;
  11.  
  12.         if (score >= record) {
  13.             System.out.printf("No, he failed! He was %.2f seconds slower.", score - record);
  14.         } else {
  15.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", score);
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement