Advertisement
veronikaaa86

06. World Swimming Record

Nov 7th, 2021
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package conditionalStatemnents;
  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 timeForUnitDistance = Double.parseDouble(scanner.nextLine());
  12.  
  13. double allTime = distance * timeForUnitDistance;
  14. double resistanceTime = Math.floor(distance / 15) * 12.5;
  15.  
  16. double totalTimePlusResistance = allTime + resistanceTime;
  17.  
  18. if (totalTimePlusResistance < worldRecord) {
  19. System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.",
  20. totalTimePlusResistance);
  21. } else {
  22. System.out.printf("No, he failed! He was %.2f seconds slower.",
  23. totalTimePlusResistance - worldRecord);
  24. }
  25. }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement