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