Advertisement
Guest User

java

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