Advertisement
CoineTre

World Record

Oct 14th, 2020
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 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 worldRecord = Double.parseDouble(scanner.nextLine());
  7.         double swimmingDistanceMeters = Double.parseDouble(scanner.nextLine());
  8.         double swimmingSecondsPerMeter = Double.parseDouble(scanner.nextLine());
  9.         double swimTimeTotal = swimmingDistanceMeters * swimmingSecondsPerMeter;
  10.         double slowDown = Math.floor(swimmingDistanceMeters / 15) * 12.5;
  11.         double totalSwimmingSeconds = swimTimeTotal + slowDown;
  12.         if (totalSwimmingSeconds < worldRecord) {
  13.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", totalSwimmingSeconds);
  14.         } else {
  15.             double secondsSlower = totalSwimmingSeconds - worldRecord;
  16.             System.out.printf("No, he failed! He was %.2f seconds slower.", secondsSlower);
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement