SHARE
TWEET

Untitled

a guest Mar 24th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 recordInSecs = Double.parseDouble(scanner.nextLine());
  9.         int distance = Integer.parseInt(scanner.nextLine());
  10.         double timeInSecsForOneMeter = Double.parseDouble(scanner.nextLine());
  11.         double timeForTotalDistance = distance * timeInSecsForOneMeter;
  12.         double addTime = (distance / 15) * 12.5;
  13.         double totalTime = timeForTotalDistance + addTime;
  14.  
  15.         if (totalTime < recordInSecs) {
  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(totalTime - recordInSecs));
  19.         }
  20.  
  21.     }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top