Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SwimmingRecord {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. double recordsTime = Double.parseDouble(scanner.nextLine());
  7. double distanceM = Double.parseDouble(scanner.nextLine());
  8. double timeToSwimm1M = Double.parseDouble(scanner.nextLine());
  9. // every 15 m - 12.5 m slow
  10. double slowTimes = (Math.round(distanceM / 15));
  11. double slowInSec = slowTimes * 12.5;
  12. double timeForDistance = distanceM * timeToSwimm1M;
  13. double finaTime = timeForDistance + slowInSec;
  14. if(finaTime>recordsTime){
  15. double notEnoughTime = finaTime - recordsTime;
  16. System.out.printf("No, he failed! He was %.2f seconds slower.", notEnoughTime);
  17.  
  18. }else{
  19. System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", finaTime);
  20.  
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement