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