public int CalculateResult(){
    int requiredGrade = 0;
    for (int x = 0; x < 4; x++){
        int grade = input.nextInt();
        int totalMarks = totalMarks + grade;
    }
    return totalMarks / 5;
    if (totalMarks < requiredGrade){
        System.out.println("You didn't pass.");
    } 
    else{
        System.out.println("You passed.");
    }
}
I'm trying to write a program that allows the user to enter the grades for a series of students, but I'm continuously getting errors with the line return totalMarks / 5 (To get the average of 5 results).
I've tried moving the return statement to within the for loop, but the compiler still won't recognize what totalMarks is.
 
     
     
     
     
    