Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class WorldSwimmingRecord_07 {
- 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 time_per_meter = Double.parseDouble(scanner.nextLine());
- double swim_time = distance * time_per_meter;
- double delay_time = Math.floor(distance / 15) * 12.5;
- double total_time = swim_time + delay_time;
- if (total_time < record) {
- System.out.printf(" Yes, he succeeded! The new world record is %.2f seconds.", total_time);
- } else {
- double need_seconds = total_time - record;
- System.out.printf("No, he failed! He was %.2f seconds slower.", need_seconds);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement