Untitled

 avatar
unknown
plain_text
2 years ago
983 B
5
Indexable
import java.util.Scanner;
public class Assignment2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int minutes = Integer.parseInt(scanner.nextLine());
        int seconds = Integer.parseInt(scanner.nextLine());
        double meters = Double.parseDouble(scanner.nextLine());
        int secsPer100 = Integer.parseInt(scanner.nextLine());
        double decrease = 0;

        int timeTotal = minutes * 60 + seconds;
        if (meters > 120) {
            decrease += meters / 120 * 2.5;
        }

        double malcomsTime = (meters / 100) * secsPer100 - decrease;

        if (malcomsTime <= timeTotal) {
            System.out.println("Malcolm Davidson won an Olympic quota!");
            System.out.printf("His time is %.3f.", malcomsTime);
        } else {
            System.out.printf("No, Malcolm failed! He was %.3f second slower.", Math.abs(malcomsTime - timeTotal));
        }

    }
}
Editor is loading...