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