Advertisement
damesova

World Swimming Records - Java

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