by Dinesh Thakur Category: array
import java.io.*;
class SumAvgArray
{
    public static void main(String args[]) throws IOException
    {
        BufferedReader gg=new BufferedReader(new InputStreamReader(System.in));
        int Number[]=new int[5];
        int i,Sum;
        float Average;
        Sum=0;
        String m;
        System.out.println("Enter Five Numbers :");
        for(i=0;i<=4;i++)
        {
            m=gg.readLine();
            Number[i]=Integer.parseInt(m);
        }
        for(i=0;i<=4;i++)
        {
            Sum=Sum+Number[i];
        }
        System.out.println("Sum is : "+Sum);
        Average=(float)Sum/5;
        System.out.println("Average is : "+Average);
    }
}

Sum and Average of Array in Java



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article