Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.  * Created by Kiril.Rechanski on 6/27/2017.
  5.  */
  6.  
  7. public class SwimmingWR {
  8.     public static void main(String[] args) {
  9.         Scanner sc = new Scanner(System.in);
  10.  
  11.         double record_s = Double.parseDouble(sc.nextLine());
  12.         double distance_m = Double.parseDouble(sc.nextLine());
  13.         double time_s = Double.parseDouble(sc.nextLine());
  14.  
  15.         //Calc how much he has to swim
  16.         double distaceNeeded = distance_m*time_s;
  17.  
  18.         //Current slowing him
  19.         double currentSlow = (Math.round(distance_m/15.0)) * 12.5;
  20.  
  21.         //Total time
  22.         double totalTime = distaceNeeded+currentSlow;
  23.  
  24.         //Checking if he has beaten the record and how much he needs to beat it
  25.  
  26.         if (record_s<totalTime) {
  27.  
  28.             double timeNeeded = totalTime-record_s;
  29.  
  30.             System.out.printf("No, he failed! He was %.2f seconds slower.", timeNeeded);
  31.         }
  32.  
  33.         else if (record_s>totalTime){
  34.  
  35.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", totalTime);
  36.  
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement