Advertisement
finderabc

World Swimming Record

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