Advertisement
Guest User

Untitled

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