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