
how to write a program to find average of 5 student marks .

Hi Friend,
Try the following code:
import java.util.*;
class AverageOfFiveStudentsMarks
{
public static void main(String[] args)
{
double sum=0;
Scanner input=new Scanner(System.in);
double marks[]=new double[5];
for(int i=0;i<marks.length;i++){
int j=i+1;
System.out.print("Enter marks of Student "+j+": ");
marks[i]=input.nextDouble();
sum+=marks[i];
}
int len=marks.length;
double average=sum/len;
System.out.println("Average of student's marks is: "+average);
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.