Create a Java class called Student that represents a student and some grades. Th
ID: 3671892 • Letter: C
Question
Create a Java class called Student that represents a student and some grades. The class should include the following five instance variables:
firstName: (type String)
lastName: (type String)
test1Grade: (type double)
test2Grade: (type double)
test3Grade: (type double)
Provide the following methods:
a constructor that sets all instance values based on input values.
Overload the constructor such that only first name and last name inputs are given and all test grades are set to zero.
setTestScore: a method that accepts two parameters, the test number (1 through 3) and the score. For example, setTestScore(1,90) means set test 1 grade to 90.
getTestScore: a method that accepts the test number and returns the appropriate score. For example, getTestScore(1) returns test 1 grade.
average: a method that computes and returns the average test score for this student.
toString: a method that returns one string the includes all student information including average score.
Write a test application named StudentDriver that demonstrates Student capabilities.
Explanation / Answer
here i am giving a java code for student grading system
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(" No Mark Grade ");
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 %d %s ", i + 1, arrMark[i], grade);
}
}
}