Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 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.  
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement