Menu
Question Index
...

Write a program to average 3 or 4 or 5 numbers passed as parameters. The data type of numbers is double.

Input Output
7.2, 4.7, 3.1 (7.2 + 4.7 + 3.1)/ 3 = 5.0
25.0, 40.4, 33.0, 2.0 (25.0 + 40.4 + 33.0 + 2.0)/ 4 = 25.1
5, 10, 15, 20, 25 (5 + 10 + 15 + 20 + 25)/ 5 = 15



class FindAverages
{
    public static void main(String s[])
    {
        Average av = new Average();
        System.out.println("Average of 7.2, 4.7 and 3.1 is " + av.average(7.2, 4.7, 3.1));
        System.out.println("Average of 25.0, 40.4, 33.0 and 2.0 is " + av.average(25.0, 40.4, 33.0, 2.0));
        System.out.println("Average of 5, 10, 15, 20 and 25 is " + av.average(5, 10, 15, 20, 25));

    }



}
class Average
{
    double average(double a, double b, double c)
    {
    }

    double average(double a, double b, double c, double d)
    {
    }

    double average(double a, double b, double c, double d, double e)
    {
    }
}

Doubts

Problems

Topic: Method Overloading 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