Advertisement
veronikaaa86

02. Mountain Run

Aug 14th, 2021
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. package examPreparation;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P02MountainRun {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. double worldRecord = Double.parseDouble(scanner.nextLine());
  10. double distanceInM = Double.parseDouble(scanner.nextLine());
  11. double timeInSecForOneM = Double.parseDouble(scanner.nextLine());
  12.  
  13. double georgiTime = distanceInM * timeInSecForOneM;
  14. double delay = Math.floor(distanceInM / 50) * 30;
  15.  
  16. double allGeorgiTime = georgiTime + delay;
  17.  
  18. if (allGeorgiTime < worldRecord) {
  19. System.out.printf("Yes! The new record is %.2f seconds.", allGeorgiTime);
  20. } else {
  21. System.out.printf("No! He was %.2f seconds slower.", allGeorgiTime - worldRecord);
  22. }
  23. }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement