Advertisement
Stani_slava

WorldSwimmingRecord

Feb 22nd, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class WorldSwimmingRecord {
  3.     public static void main(String[] args) {
  4.          Scanner scanner = new Scanner(System.in);
  5.  
  6.          double worldRecord = Double.parseDouble(scanner.nextLine());
  7.          double distance = Double.parseDouble(scanner.nextLine());
  8.          double timeFor1Meter = Double.parseDouble(scanner.nextLine());
  9.  
  10.          double ivanScore = distance * timeFor1Meter;
  11.          double waterResistance = Math.floor(distance) /15 * 12.5;
  12.          double totalTime = ivanScore + waterResistance;
  13.          double notEnough = worldRecord - totalTime;
  14.  
  15.          if (totalTime > worldRecord){
  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.", notEnough);
  19.          }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement