KnowledgeBoat Logo

Computer Applications

Write a program to find the sum and average of three numbers.

Java

Java Intro

165 Likes

Answer

public class KboatSumAvg
{
    public static void computeSumAvg(int a, int b, int c) {
        System.out.println("The three numbers are " 
          + a + ", " + b + ", " + c );
        int sum = a + b + c;
        double avg = sum / 3.0;
        System.out.println("Sum = " + sum);
        System.out.println("Average = " + avg);
    }
}

Output

BlueJ output of Write a program to find the sum and average of three numbers.

Answered By

65 Likes


Related Questions