Advertisement
Kancho

World Swim Record

Jan 23rd, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class World_Swim_Record {
  4. public static void main(String [] args){
  5.  
  6. Scanner keyboard = new Scanner (System.in);
  7. System.out.print("Enter world's record - sec.: ");
  8. int worldRecord = keyboard.nextInt();
  9. System.out.print("Enter distance - meters: ");
  10. int distance = keyboard.nextInt();
  11. System.out.print("Enter seconds per a meter: ");
  12. double secondsPerMeter = keyboard.nextDouble();
  13. double waterResistance = Math.ceil((distance / 15) * 12.5);
  14. System.out.printf("%.0f seconds %n",waterResistance);
  15. double swimTime = (distance * secondsPerMeter) + waterResistance;
  16. System.out.printf("Ivan swam %.0f seconds %n" ,swimTime);
  17. if (swimTime < worldRecord){
  18. System.out.printf("Yes, he succeeded! The new record is %.0f seconds! ",swimTime);
  19. } else {
  20. double failResult = Math.abs(worldRecord - swimTime);
  21. System.out.printf("No, he failed to improve the world record! He is %.0f seconds slower.", failResult);
  22. }
  23.  
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement