Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class World_Swim_Record {
- public static void main(String [] args){
- Scanner keyboard = new Scanner (System.in);
- System.out.print("Enter world's record - sec.: ");
- int worldRecord = keyboard.nextInt();
- System.out.print("Enter distance - meters: ");
- int distance = keyboard.nextInt();
- System.out.print("Enter seconds per a meter: ");
- double secondsPerMeter = keyboard.nextDouble();
- double waterResistance = Math.ceil((distance / 15) * 12.5);
- System.out.printf("%.0f seconds %n",waterResistance);
- double swimTime = (distance * secondsPerMeter) + waterResistance;
- System.out.printf("Ivan swam %.0f seconds %n" ,swimTime);
- if (swimTime < worldRecord){
- System.out.printf("Yes, he succeeded! The new record is %.0f seconds! ",swimTime);
- } else {
- double failResult = Math.abs(worldRecord - swimTime);
- System.out.printf("No, he failed to improve the world record! He is %.0f seconds slower.", failResult);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement