Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ExamPreparation;
- import java.util.Scanner;
- public class MountainRun {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double record = Double.parseDouble(scanner.nextLine());
- double distance = Double.parseDouble(scanner.nextLine());
- double timePerMeter = Double.parseDouble(scanner.nextLine());
- double slowdown = Math.floor((distance / 50) * 30);
- double time = distance * timePerMeter + slowdown;
- if (time < record) {
- System.out.printf("Yes! The new record is %.2f seconds.", time);
- } else {
- System.out.printf("No! He was %.2f seconds slower.", Math.abs(record - time));
- }
- }
- }
Add Comment
Please, Sign In to add comment