SHARE
TWEET

Untitled

a guest Nov 19th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  7.         double recordInCm = Double.parseDouble(scan.nextLine());
  8.         double distanceM = Double.parseDouble(scan.nextLine());
  9.         double timeSec = Double.parseDouble(scan.nextLine());
  10.  
  11.         double swimmingDistance = distanceM * timeSec;
  12.         double swimming = Math.round(distanceM / 15);
  13.         double swimmingAdd = swimming * 12.5;
  14.         double swimmingTime = swimmingDistance + swimmingAdd;
  15.  
  16.         if (recordInCm > swimmingTime) {
  17.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", swimmingTime);
  18.         } else if (recordInCm < swimmingTime) {
  19.             double time = swimmingTime - recordInCm;
  20.             System.out.printf("No, he failed! He was %.2f seconds slower.", time);
  21.         }
  22.     }
  23. }
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