Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class WorldRecordSwim {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double recordInSeconds = Double.parseDouble(scanner.nextLine());
  8.         double distanceMeter = Double.parseDouble(scanner.nextLine());
  9.         double timeInSeconds = Double.parseDouble(scanner.nextLine());
  10.  
  11.         double seconds = distanceMeter * timeInSeconds;
  12.         double resistance = Math.floor((distanceMeter / 15) * 12.5);
  13.         double totalTime = seconds + resistance;
  14.  
  15.         if(totalTime <= recordInSeconds){
  16.             System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", totalTime);
  17.         }
  18.         else{
  19.             System.out.printf("No, he failed! He was %.2f seconds slower.", totalTime - recordInSeconds);
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement