Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SwimmingRecord {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double recordInSeconds = Double.parseDouble(scan.nextLine());
- double distanceInMeters = Double.parseDouble(scan.nextLine());
- double secondsPerMeter = Double.parseDouble(scan.nextLine());
- double travelTime = distanceInMeters * secondsPerMeter;
- double travelSlow = Math.floor(distanceInMeters / 15) * 12.5;
- double totalTimeTravel = travelTime / travelSlow;
- if(recordInSeconds < totalTimeTravel){
- System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", totalTimeTravel);
- }else if(totalTimeTravel<recordInSeconds){
- double timeLeft =recordInSeconds - totalTimeTravel;
- System.out.printf("No, he failed! He was %.2f seconds slower.",timeLeft);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement