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