Advertisement
desislava_topuzakova

Untitled

Jan 23rd, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class SwimmingRecord {
  3. public static void main(String[] args) {
  4. Scanner scanner=new Scanner(System.in);
  5.  
  6. double record=Double.parseDouble(scanner.nextLine());
  7. double distance=Double.parseDouble(scanner.nextLine());
  8. double timePerMeter=Double.parseDouble(scanner.nextLine());
  9. double needTime=distance*timePerMeter;
  10.  
  11. double zab=Math.floor(distance/15)*12.5;
  12. double sumTime=zab+needTime;
  13.  
  14. if(sumTime>=record){
  15.  
  16. double raz=sumTime-record;
  17. System.out.print("No, he failed! He was ");
  18. System.out.printf("%.2f",raz);
  19. System.out.print(" seconds slower.");
  20. }
  21. else if(sumTime<record){
  22.  
  23. System.out.print("Yes, he succeeded! The new world record is ");
  24. System.out.printf("%.2f",sumTime);
  25. System.out.print(" seconds.");
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement