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 recordsTime = Double.parseDouble(scanner.nextLine());
- double distanceM = Double.parseDouble(scanner.nextLine());
- double timeToSwimm1M = Double.parseDouble(scanner.nextLine());
- // every 15 m - 12.5 m slow
- double slowTimes = (Math.round(distanceM / 15));
- double slowInSec = slowTimes * 12.5;
- double timeForDistance = distanceM * timeToSwimm1M;
- double finaTime = timeForDistance + slowInSec;
- if(finaTime>recordsTime){
- double notEnoughTime = finaTime - recordsTime;
- System.out.printf("No, he failed! He was %.2f seconds slower.", notEnoughTime);
- }else{
- System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", finaTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement