Advertisement
Guest User

7.Swimming

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