Advertisement
todor_boichev

Untitled

Sep 20th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. package ConditionalStatements.Exercise;
  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 distance = Double.parseDouble(scanner.nextLine());
  10.         double timeMeters = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double time = distance * timeMeters;
  13.         double totalTime = Math.floor(distance / 15) * 12.5 + time;                                                                                   //31250
  14.  
  15.         if (worldRecord < totalTime) {
  16.             System.out.printf("No, he failed!" +
  17.                     " He was %.2f seconds slower.", totalTime - worldRecord);
  18.         } else  {
  19.             System.out.printf("Yes, he succeeded!" +
  20.                     " The new world record is %.2f seconds.", totalTime);
  21.         }
  22.  
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement