TZinovieva

Mountain Run 100/100

Apr 15th, 2022 (edited)
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package ExamPreparation;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class MountainRun {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         double record = Double.parseDouble(scanner.nextLine());
  10.         double distance = Double.parseDouble(scanner.nextLine());
  11.         double timePerMeter = Double.parseDouble(scanner.nextLine());
  12.  
  13.         double slowdown = Math.floor((distance / 50) * 30);
  14.         double time = distance * timePerMeter + slowdown;
  15.  
  16.         if (time < record) {
  17.             System.out.printf("Yes! The new record is %.2f seconds.", time);
  18.         } else {
  19.             System.out.printf("No! He was %.2f seconds slower.", Math.abs(record - time));
  20.         }
  21.     }
  22. }
  23.  
Add Comment
Please, Sign In to add comment