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