Menu
Question Index
...

What will be the output of the following program?

public class DailyDoseAmount
{
    public static void main(String[] args)
    {
        printAmount(40, 0);
        printAmount(350, 28);
        printAmount(528, 72);
        printAmount(713, 129);
        printAmount(687, 634);
        printAmount(812, 389);
    }

    public static void printAmount(int numberOfFriends, int numberOfFollowers)
    {
        int amount = (numberOfFriends + numberOfFollowers) / 100;
        amount *= 10;
        amount = Math.max(40, amount);
        amount = Math.min(100, amount);
        System.out.println("For " + numberOfFriends + " Friends and " + numberOfFollowers + " Followers, the amount is " + amount);
    }
}


For 40 Friends and 0 Followers, the amount is 0
For 350 Friends and 28 Followers, the amount is 30
For 528 Friends and 72 Followers, the amount is 40
For 713 Friends and 129 Followers, the amount is 40
For 687 Friends and 634 Followers, the amount is 40
For 812 Friends and 389 Followers, the amount is 40
For 40 Friends and 0 Followers, the amount is 40
For 350 Friends and 28 Followers, the amount is 40
For 528 Friends and 72 Followers, the amount is 60
For 713 Friends and 129 Followers, the amount is 80
For 687 Friends and 634 Followers, the amount is 100
For 812 Friends and 389 Followers, the amount is 100
For 40 Friends and 0 Followers, the amount is 100
For 350 Friends and 28 Followers, the amount is 100
For 528 Friends and 72 Followers, the amount is 100
For 713 Friends and 129 Followers, the amount is 100
For 687 Friends and 634 Followers, the amount is 130
For 812 Friends and 389 Followers, the amount is 120
Compilation Error

Doubts

Problems

Topic: Java Methods - Parameter Passing And Scope

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App