Program to find average of three numbers using function in java.

import java.util.*;
public class function {
    public static void average(int a,int b, int c){
       float avg=(a+b+c)/3;
        System.out.print("the average of three numbers is="+avg);
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("enter three numbers=");
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        average(a,b,c);
    }
}

■》Output->

enter three numbers=>
4
5
6

the average of three numbers is= 5.0

Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.