Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ConditionalStatements;
- 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 distanceInMeters = Double.parseDouble(scanner.nextLine());
- double timeForOneMeter = Double.parseDouble(scanner.nextLine());
- double timeForDistance = distanceInMeters * timeForOneMeter;
- double delay = Math.floor(distanceInMeters / 15) * 12.5;
- double totalTime = timeForDistance + delay;
- if (totalTime < worldRecord) {
- 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.",Math.abs(worldRecord - totalTime));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement