Advertisement
Darina0792

Untitled

Jan 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SwimmingRecords {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double seconds = Double.parseDouble(scanner.nextLine());
  8. double meters = Double.parseDouble(scanner.nextLine());
  9. double timeInSecPerMeter = Double.parseDouble(scanner.nextLine());
  10.  
  11. double distanceInSec = meters * timeInSecPerMeter;
  12. double resistance = (meters / 15) * 12.5;
  13. double time = distanceInSec + resistance;
  14. double timeResult = Math.floor(time);
  15.  
  16. double noTime = time - seconds;
  17. double nooTime = Math.floor(noTime);
  18.  
  19. if (seconds > time ){
  20. System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.",timeResult);
  21. }else if (seconds < time){
  22. System.out.printf("No, he failed! He was %.2f seconds slower.", nooTime);
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement