Write a program in java to find the sum and average of three numbers by using assignment function argument
Answers
Answered by
1
Answer:
import java.util.Scanner;
public class Main
{
static double average(int a , int b , int c){
return (a+b+c)/3.0d;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the first number:");
int a = sc.nextInt();
System.out.print("Enter the second number:");
int b = sc.nextInt();
System.out.print("Enter the third number:");
int c = sc.nextInt();
System.out.println("The average of " + a + " " + b + " and " + c + " is " + average(a,b,c));
}
}
Explanation:
Similar questions