Advertisement
veronikaaa86

World Record

Oct 29th, 2017
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 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 resMath = Math.floor(resistance);
  14.         double fullTime = secDistanceM+resistance;
  15.  
  16.         double slow = fullTime-worldRecord;;
  17.  
  18.         if (fullTime<worldRecord) {
  19.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", fullTime);
  20.         } else {
  21.             System.out.printf("No, he failed! He was %.2f seconds slower.", slow);
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement