Advertisement
desislava_topuzakova

Untitled

Apr 30th, 2020
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class WorldSwimmingRecord_07 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. double record = Double.parseDouble(scanner.nextLine());
  7. double distance = Double.parseDouble(scanner.nextLine());
  8. double time_per_meter = Double.parseDouble(scanner.nextLine());
  9.  
  10. double swim_time = distance * time_per_meter;
  11. double delay_time = Math.floor(distance / 15) * 12.5;
  12. double total_time = swim_time + delay_time;
  13.  
  14. if (total_time < record) {
  15. System.out.printf(" Yes, he succeeded! The new world record is %.2f seconds.", total_time);
  16. } else {
  17. double need_seconds = total_time - record;
  18.  
  19. System.out.printf("No, he failed! He was %.2f seconds slower.", need_seconds);
  20.  
  21.  
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement