Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.SoftUni;
- import java.util.Scanner;
- public class Problem07 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- //input
- double record = Double.parseDouble(scan.nextLine()); //world record
- double distanceMeters = Double.parseDouble(scan.nextLine());
- double timeInSecPerMeter = Double.parseDouble(scan.nextLine()); //your speed per meter
- double yourTime = distanceMeters * timeInSecPerMeter;
- double waterDrag = Math.floor(distanceMeters / 15) * 12.5;
- double totalTime = yourTime + waterDrag;
- double difference = 0;
- //check-ups
- if (record > totalTime) {
- System.out.printf("Yes, he succeeded! The new world record is %.2f seconds.", totalTime);
- }else {
- difference = (record - totalTime) * (-1);
- System.out.printf("No, he failed! He was %.2f seconds slower.", difference);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement