Java program to calculate average marks


Introduction

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

class AverageMarks
{
                    public static void main(String arg[])
                    {
                    int n=5,avg=0;
 
                    int arr[]=new int[n];
 
    arr[0]=80; 
    arr[1]=70; 
    arr[2]=60; 
    arr[3]=50; 
    arr[4]=40;
 
                    for(int i=0;i<n;i++)
 
    avg = avg+arr[i];
 
    System.out.println("average of  ("+arr[0]+","+arr[1]+","+arr[2]+","+arr[3]+","+arr[4]+")  is = "+ avg/n);
 
                    }
}

Result

java techstudy.org

     





Related Topics




Popular Posts