Java Student Grading System
I have given here Java source code for student grading system which accepts the mark as input and assigns ranking from A+ to F.
Source Code
import java.lang.*;
import java.util.*;
import java.io.*;
class StudentGrade
{
public static int ReadInteger()
{
try
{
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(input);
return Integer.parseInt(reader.readLine());
}
catch (Exception e)
{
e.printStackTrace();
return 0;
}
}
public static void main(String[] args)
{
System.out.println("Program for simple student grading logic.");
int MAX_STUDENTS = 10;
int [] arrMark = new int[MAX_STUDENTS];
String grade = "";
for (int i = 0; i < MAX_STUDENTS; i++)
{
System.out.format("Enter %d Student Mark: ", i + 1);
arrMark[i] = ReadInteger();
}
System.out.print("\n\nNo\tMark\tGrade\n");
for (int i = 0; i < MAX_STUDENTS; i++)
{
if(arrMark[i] > 100)
grade = "Error";
else if(arrMark[i] > 90)
grade = "A+";
else if(arrMark[i] > 70)
grade = "B+";
else if(arrMark[i] > 50)
grade = "C+";
else if(arrMark[i] > 30)
grade = "C";
else
grade = "F";
System.out.format("%d\t%d\t%s\n", i + 1, arrMark[i], grade);
}
}
}
Output
Enter 1 Student Mark: 65
Enter 2 Student Mark: 76
Enter 3 Student Mark: 89
Enter 4 Student Mark: 95
Enter 5 Student Mark: 20
Enter 6 Student Mark: 45
Enter 7 Student Mark: 55
Enter 8 Student Mark: 67
Enter 9 Student Mark: 89
Enter 10 Student Mark: 29
No Mark Grade
1 65 C+
2 76 B+
3 89 B+
4 95 A+
5 20 F
6 45 C
7 55 C+
8 67 C+
9 89 B+
10 29 F
Press any key to continue . . .
|