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