Menu
Question Index
...

What is the output of the following program?

public class AutoFare {

    private static final double MINIMUM_CHARGE = 16.0;
    protected static final double PRICE_PER_KM = 9.25;
    public static final double WAITING_CHARGE_PER_MIN = 0.50;

    public static void main(String[] args) {
        System.out.print(calculate(0.5, 12) + "@");
        System.out.print(calculate(12, 0) + "@");
        System.out.print(calculate(1, 200) + "@");
        System.out.print(calculate(8.25, 3) + "@");
    }

    private static int calculate(double kms, int minutes) {
        return Math.rint(Math.min(kms * PRICE_PER_KM + WAITING_CHARGE_PER_MIN, MINIMUM_CHARGE));
    }
}


5@16@10@16@
5@16@9@16@
16@111@16@76@
Compilation Error or Runtime Error

Doubts

Problems

Topic: Static Keyword In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App