Advertisement
SotirovG

WorldSwimmingRecord_06/70/100

Sep 19th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.69 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class WorldSwimmingRecord_06 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         // тотално време в секунди
  7.         // Разстоянието в метри
  8.         // Времето в секунди, за което плува разстояние от 1 м.
  9.  
  10.         double worldRecord = Double.parseDouble(scanner.nextLine()); //10464 сек
  11.         double distance = Double.parseDouble(scanner.nextLine()); // 1500m
  12.         double timeInSec = Double.parseDouble(scanner.nextLine());//20 сек за м
  13.  
  14.         double distanceInSec = distance * timeInSec; // дистанция за плуване в секунди 30000 сек
  15.         double retard = Math.floor(distance / 15); // забавянето му 100
  16.         double retardInSec = retard * 12.5; // забавянето му за 1500 м = 12500 сек
  17.  
  18.         double totalTime = distanceInSec + retardInSec;
  19.  
  20.  
  21.         if (worldRecord < totalTime){
  22.             double neededTime = Math.floor(totalTime - worldRecord);
  23.             System.out.printf("No, he failed! He was %.2f seconds slower.",neededTime);
  24.         }else {
  25.             double newRecord = distanceInSec + retardInSec;
  26.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.",newRecord);
  27.           }
  28.  
  29.         /*if( totalTime<worldRecord){
  30.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.",totalTime);
  31.         }else {
  32.             double neededTime = totalTime - worldRecord;
  33.             System.out.printf("No, he failed! He was %.2f seconds slower.",neededTime);
  34.         }*/
  35.  
  36.  
  37.  
  38.  
  39.     }
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement