Advertisement
Deiancom

Swimming Record

Jan 25th, 2020
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. package ConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class WorldSwimmingRecord {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         double worldRecord = Double.parseDouble(scanner.nextLine());
  9.         double distanceInMeters = Double.parseDouble(scanner.nextLine());
  10.         double timeForOneMeter = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double timeForDistance = distanceInMeters * timeForOneMeter;
  13.         double delay = Math.floor(distanceInMeters / 15) * 12.5;
  14.         double totalTime = timeForDistance + delay;
  15.         if (totalTime < worldRecord) {
  16.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.",totalTime);
  17.         }else {
  18.             System.out.printf("No, he failed! He was %.2f seconds slower.",Math.abs(worldRecord - totalTime));
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement