Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class O7WorldSwimmingRecord {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double worldRecordSeconds = Double.parseDouble(scanner.nextLine());
- double distanceMetres = Double.parseDouble(scanner.nextLine());
- double timeInSecondsPerMeter = Double.parseDouble(scanner.nextLine());
- double swimming = distanceMetres * timeInSecondsPerMeter ;
- double plusSwimming = Math.floor(distanceMetres / 15)* 12.5;
- double totalTime = swimming + plusSwimming;
- if(totalTime >= worldRecordSeconds)
- {
- System.out.printf("No, he failed! He was %.2f seconds slower.", totalTime - worldRecordSeconds);
- }else
- {
- System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.",totalTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement