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