deyanivanov966

07. World Swimming Record

Aug 23rd, 2020 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 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 timeForMeter= Double.parseDouble(scanner.nextLine());
  9.         double time= distance*timeForMeter;
  10.         double delay= Math.floor(distance/15);
  11.         double totalDelay= delay*12.5;
  12.         double totalTime= time+totalDelay;
  13.         if(totalTime<record){
  14.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", totalTime);
  15.         }else{
  16.             System.out.printf("No, he failed! He was %.2f seconds slower.",totalTime-record);
  17.         }
  18.     }
  19. }
Add Comment
Please, Sign In to add comment