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 scan = new Scanner(System.in);
- double record = Double.parseDouble(scan.nextLine());
- double distance = Double.parseDouble(scan.nextLine());
- double timeInSecondsForOneMeter = Double.parseDouble(scan.nextLine());
- double timeToSwim = distance*timeInSecondsForOneMeter;
- double secondsDelay = Math.round(distance/15)*12.5;
- double totalTime = timeToSwim+secondsDelay;
- double differenceBetweenTimes = totalTime-record;
- if (totalTime<record) {
- System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", totalTime);
- } else {
- System.out.printf("No, he failed! He was %.2f seconds slower.", differenceBetweenTimes);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement