Advertisement
veronikaaa86

02. Mountain Run

Aug 13th, 2022
1,037
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. package examPrep;
  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 record = Double.parseDouble(scanner.nextLine());
  10.         double distance = Double.parseDouble(scanner.nextLine());
  11.         double timeInSecOneM = Double.parseDouble(scanner.nextLine());
  12.  
  13.         double georgiTime = distance * timeInSecOneM;
  14.         double delay = Math.floor(distance / 50) * 30;
  15.         double totalTime = georgiTime + delay;
  16.  
  17.         if (totalTime < record) {
  18.             System.out.printf("Yes! The new record is %.2f seconds.", totalTime);
  19.         } else {
  20.             double diff = totalTime - record;
  21.             System.out.printf("No! He was %.2f seconds slower.", diff);
  22.         }
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement