EliPerfanova

World Swimming Record

Sep 15th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class WorldSwimmingRecord {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double record = Double.parseDouble(scanner.nextLine());
  7.         double way = Double.parseDouble(scanner.nextLine());
  8.         double time1m = Double.parseDouble(scanner.nextLine());
  9.  
  10.         double hasToSwim = way * time1m;
  11.         double timeAdded = Math.floor(way / 15)* 12.5;
  12.  
  13.  
  14.         double allTime = hasToSwim + timeAdded;
  15.         double need = allTime - record;
  16.  
  17.         if (allTime >= record){
  18.             System.out.printf("No, he failed! He was %.2f seconds slower.",need);
  19.         }
  20.         else if (record >= allTime){
  21.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.",Math.abs(allTime));
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment