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);
- double worldRecord = Double.parseDouble(scanner.nextLine());
- double swimmingDistanceMeters = Double.parseDouble(scanner.nextLine());
- double swimmingSecondsPerMeter = Double.parseDouble(scanner.nextLine());
- double swimTimeTotal = swimmingDistanceMeters * swimmingSecondsPerMeter;
- double slowDown = Math.floor(swimmingDistanceMeters / 15) * 12.5;
- double totalSwimmingSeconds = swimTimeTotal + slowDown;
- if (totalSwimmingSeconds < worldRecord) {
- System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", totalSwimmingSeconds);
- } else {
- double secondsSlower = totalSwimmingSeconds - worldRecord;
- System.out.printf("No, he failed! He was %.2f seconds slower.", secondsSlower);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement