Hi,
The whole idea of this program is allow teachers to input marks results for 6 students. Once all marks have been entered, It must to display the marks and grade for each student.
For some reason it can't display the grade properly.
It just display "Fail" on each mark.
If somebody can help me, I'd appreciate.
Thank you.
import java.util.Scanner;
public class ExamMarks
{
public static void main(String[] args)
{
int marks = 0;
String g = "";
int[] sNumb = new int[6];
Scanner scan = new Scanner(System.in);
for (int i = 0; i < sNumb.length ; i++)
{
System.out.println("Enter mark of student " + (i+1) ); //increment int by one
sNumb[i]= scan.nextInt();
}
for (int i = 0; i < sNumb.length ; i++)
{
if (marks <= 39)
{
g = "Fail";
}
else
if (marks >= 40 && marks <= 64)
{
g = "Pass";
System.out.println(" Student " + (i + 1) + " received a mark of " + sNumb [i] + " and a " + g + " grade ");
}
else
if (marks >= 65 && marks <= 84)
{
g = "Merit";
System.out.println(" Student " + (i + 1) + " received a mark of " + sNumb [i] + " and a " + g + " grade ");
}
else
if (marks >= 85 && marks <= 100)
{
g = "Distinction";
System.out.println(" Student " + (i + 1) + " received a mark of " + sNumb [i] + " and a " + g + " grade ");
}
System.out.println(" Student " + (i + 1) + " received a mark of " + sNumb [i] + " and a " + g + " grade ");
}
}
}