Advertisement
Silviyaa

07. World Swimming Record

Feb 25th, 2021
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class O7WorldSwimmingRecord {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double worldRecordSeconds = Double.parseDouble(scanner.nextLine());
  8.         double distanceMetres = Double.parseDouble(scanner.nextLine());
  9.         double timeInSecondsPerMeter = Double.parseDouble(scanner.nextLine());
  10.  
  11.         double swimming = distanceMetres * timeInSecondsPerMeter ;
  12.         double plusSwimming = Math.floor(distanceMetres / 15)* 12.5;
  13.  
  14.         double totalTime = swimming + plusSwimming;
  15.  
  16.         if(totalTime >= worldRecordSeconds)
  17.         {
  18.             System.out.printf("No, he failed! He was %.2f seconds slower.", totalTime - worldRecordSeconds);
  19.         }else
  20.         {
  21.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.",totalTime);
  22.         }
  23.  
  24.  
  25.  
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement