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());
- double distanceToSwimInMeters = Integer.parseInt(scanner.nextLine());
- double timeInSecsFor1meter = Double.parseDouble(scanner.nextLine());
- double timeForFullDistance = distanceToSwimInMeters * timeInSecsFor1meter;
- double opositionInSecs = Math.floor (distanceToSwimInMeters / 15 );
- double roundedOposition = opositionInSecs * 12.5;
- double sumTime = timeForFullDistance + roundedOposition;
- if (sumTime >= recordToReachInSecs ){
- 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