Advertisement
veronikaaa86

06. World Swimming Record

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