Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * Created by Kiril.Rechanski on 6/27/2017.
- */
- public class SwimmingWR {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- double record_s = Double.parseDouble(sc.nextLine());
- double distance_m = Double.parseDouble(sc.nextLine());
- double time_s = Double.parseDouble(sc.nextLine());
- //Calc how much he has to swim
- double distaceNeeded = distance_m*time_s;
- //Current slowing him
- double currentSlow = (Math.round(distance_m/15.0)) * 12.5;
- //Total time
- double totalTime = distaceNeeded+currentSlow;
- //Checking if he has beaten the record and how much he needs to beat it
- if (record_s<totalTime) {
- double timeNeeded = totalTime-record_s;
- System.out.printf("No, he failed! He was %.2f seconds slower.", timeNeeded);
- }
- else if (record_s>totalTime){
- System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", totalTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement