Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package S2_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 distance = Double.parseDouble(scanner.nextLine());
- double timeFor1Meter = Double.parseDouble(scanner.nextLine());
- double timeForSwimming = distance * timeFor1Meter;
- double sectorsInDistance = Math.floor(distance / 15);
- double slowingTime = sectorsInDistance * 12.5;
- timeForSwimming = timeForSwimming + slowingTime;
- if(timeForSwimming < record) {
- System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", timeForSwimming);
- } else {
- double diff = timeForSwimming - record;
- System.out.printf("No, he failed! He was %.2f seconds slower.", diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement