Computer Science, asked by Ehsanul885, 1 month ago

Write a program in java to find and display the sum and average of the three numbers by using function argument.

Answers

Answered by brainlyehsanul
49

Explanation :

// To find the sum and average of three numbers by using function argument

public class Average

{

public static void main (int a, int b, int c)

{

int sum=0;

float avg=0.0;

sum=(a+b+c);

avg=sum/3.0;

System.out.println("The sum ="+sum);

System.out.println("The average ="+avg);

}

}

Answered by misssonali2006
1

Answer:

Find sum and average of two numbers in Java

import java.util.*;

public class Numbers {

public static void main(String args[]) {

int a, b, sum;

float avg;

Scanner buf = new Scanner(System.in);

System.out.print("Enter first number : ");

a = buf.nextInt();

System.out.print("Enter second number : ");

b = buf.nextInt();

/*Calculate sum and average*/

sum = a + b;

avg = (float)((a + b) / 2);

System.out.print("Sum : " + sum + "\nAverage : " + avg);

}

Similar questions