Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class WorldSwimmingRecord {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // READ
- //1. record in seconds to reach
- //2. distance to swim in meters
- //3. time in second for 1m
- // KNOW
- //1. water oposition, each 15m, slows down the swimmer with 12.5sec
- double recordToReachInSecs = Double.parseDouble(scanner.nextLine());
- int distanceToSwimInMeters = Integer.parseInt(scanner.nextLine());
- double timeInSecsFor1meter = Double.parseDouble(scanner.nextLine());
- double timeForFullDistance = distanceToSwimInMeters * timeInSecsFor1meter; // 3017 * 5.03 = 15,175.51
- double opositionInSecs = distanceToSwimInMeters / 15;
- double roundDown = Math.floor(opositionInSecs);// 3017 / 15
- double roundedOposition = roundDown * 12.5;//201 * 12.5=
- double sumTime = timeForFullDistance + roundedOposition;
- if (recordToReachInSecs <= sumTime ){
- double missingSecs = sumTime -recordToReachInSecs ;
- System.out.printf("No, he failed! He was %.2f seconds slower.", missingSecs);
- } else {
- System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.",sumTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement