Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapp;
- import java.util.Scanner;
- public class WorldRecord {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double WorldRecord = Double.parseDouble(scanner.nextLine());
- double Distance = Double.parseDouble(scanner.nextLine());
- double Time = Double.parseDouble(scanner.nextLine());
- double SmoothDive = Distance*Time;
- double Resistance=Math.floor(((Distance/15)*12.5));
- double TotalTime=SmoothDive+Resistance;
- double TimeLeft=TotalTime-WorldRecord;
- if (TotalTime<WorldRecord) {
- System.out.printf(" Yes, he succeeded! The new world record is %.2f seconds.",TotalTime);
- } else if (TotalTime==WorldRecord) {
- System.out.printf("No, he failed! He was %.2f seconds slower.",TimeLeft);
- } else {
- System.out.printf("No, he failed! He was %.2f seconds slower.",TimeLeft);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment