Advertisement
Angel_Kalinkov

PBE-17June2017-WorldSwimmingRecord_AngelKalinkov

Jan 17th, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 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.  
  7.         double record = Double.parseDouble(scanner.nextLine());
  8.         double distance = Double.parseDouble(scanner.nextLine());
  9.         double mForSeconds = Double.parseDouble(scanner.nextLine());
  10.  
  11.         double swimmingTime = distance * mForSeconds + Math.floor(distance / 15) * 12.5;
  12.         double difference = swimmingTime - record;
  13.  
  14.         if (swimmingTime < record) {
  15.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.%n", swimmingTime);
  16.         } else {
  17.             System.out.printf("No, he failed! He was %.2f seconds slower.%n", difference);
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement