Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the posted data file called grades.dat that has a list of five students an

ID: 3621663 • Letter: G

Question

Given the posted data file called grades.dat that has a list of five students and their marks on 6 tests, write a program that will:
1. Create two arrays. One will be called student and will be an array of five Strings. The second will be a two dimensional array of integer values called mark.
2. Populate the arrays by connecting a scanner object to the file and reading the data into the arrays.
3. Display the arrays with appropriate headings such as:
a. Student Test1 test2 test3 test4 test5 test6
4. Create an array of five double values called studentAverage and populate it with the averages of the grades of the five students.
5. Create an array of double values called testAverages with six elements and populate it with the averages of the marks on the six tests.
6. Display the arrays with the student averages following the student marks and the test averages below the test marks.
7. Display the student’s name and mark for the student with the highest mark on each test.
8. Display the name and average of the student with the highest average on the tests.
Use methods for parts 4, 5, 7 and 8

Explanation / Answer

Dear..

public class Grade extends JFrame
{
private static final int WIDTH = 500;
private static final int HEIGHT = 410;
int gradeCalc;
int Student;
private StudentList[] sList = new StudentList[20];
private static final int MAX_NUMBER_OF_STUDENTS = 20;
private int noOfStudents;
private double score, test1, test2, test3;
private double classAvg, stAvg, totalScore;
private int displayedStudentIndex = 0;
private char ltrGrade;
private String stName;
private JLabel stNameL, test1L, test2L, test3L,
classAvgL, stAvgL, headingL;
private JTextField stNameTF, test1TF, test2TF, test3TF;
private JTextArea classAvgTA, stAvgTA;
private JButton exitB, nextB, prevB, calcGrade;
private ButtonHandler bHandler;
public SuperProject()
{
setTitle("Grade Calculator");
setSize(WIDTH, HEIGHT);
Container pane = getContentPane();
pane.setLayout(null);
bHandler = new ButtonHandler();
headingL = new JLabel("STUDENT RECORD");
stNameL = new JLabel("Student Name", SwingConstants.RIGHT);
tst1L = new JLabel("Test 1", SwingConstants.LEFT);
tst2L = new JLabel("Test 2", SwingConstants.LEFT);
tst3L = new JLabel("Test 3", SwingConstants.LEFT);
stAvgL = new JLabel("Student Average " + " " + "Class Average");
stNameTF = new JTextField(65);
tst1TF = new JTextField(10);
tst2TF = new JTextField(10);
tst3TF = new JTextField(10);
classAvgTA = new JTextArea(6, 20);
classAvgTA.setAutoscrolls(true);
exitB = new JButton("Exit");
exitB.addActionListener(bHandler);
nextB = new JButton("Next");
nextB.addActionListener(bHandler);
prevB = new JButton("Previous");
prevB.addActionListener(bHandler);
calcGrade = new JButton("Calc Grade");
calcGrade.addActionListener(bHandler);
headingL.setSize(200, 30);
stNameL.setSize(100, 30);
stNameTF.setSize(100, 30);
tst1L.setSize(100, 30);
tst1TF.setSize(100, 30);
tst2L.setSize(120, 30);
tst2TF.setSize(100, 30);
tst3L.setSize(100, 30);
tst3TF.setSize(100, 30);
classAvgTA.setSize(370, 120);
calcGrade.setSize(100, 30);
prevB.setSize(100, 30);
nextB.setSize(100, 30);
exitB.setSize(100, 30);
headingL.setLocation(220, 10);
stNameL.setLocation(20, 50);
stNameTF.setLocation(120, 50);
tst1L.setLocation(20, 100);
tst1TF.setLocation(120, 100);
tst2L.setLocation(300, 50);
tst2TF.setLocation(420, 50);
tst3L.setLocation(300, 100);
tst3TF.setLocation(420, 100);
classAvgTA.setLocation(70, 230);
prevB.setLocation(120, 370);
exitB.setLocation(220, 370);
nextB.setLocation(320, 370);
calcGrade.setLocation(420, 370);
pane.add(headingL);
pane.add(stNameL);
pane.add(stNameTF);
pane.add(tst1L);
pane.add(tst1TF);
pane.add(tst2L);
pane.add(tst2TF);
pane.add(tst3L);
pane.add(classAvgTA);
pane.add(calcGrade);
pane.add(prevB);
pane.add(exitB);
pane.add(nextB);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
System.exit(0);
}

private class ButtonHandler implements ActionListener
{
public void actionPerformed (ActionEvent e)
{
if (e.getActionCommand().equals("Previous"))
if (displayedStudentIndex > 0)
displayGradeAverage(displayedStudentIndex - 1);
else
displayGradeAverage(displayedStudentIndex);
else if (e.getActionCommand().equals("Next"))
if (displayedStudentIndex + 1 < noOfStudents)
displayGradeAverage(displayedStudentIndex + 1);
else
displayGradeAverage(displayedStudentIndex);
else if (e.getActionCommand().equals("Calc Grade"))
displayGradeAverage(0);
else
System.exit(0);
}

public static void main (String [] args)
{
new Grade();
}

Scanner inFile = new Scanner(new FileReader("AcademicGrades.txt"));
{
for (int s = 0; s < MAX_NUMBER_OF_STUDENTS; s++)
gradeCalc.StudentList[s] = new Student();
gradeCalc.noOfStudents =
inFile.nextInt();
gradeCalc.score =
inFile.nextDouble();
gradeCalc.getStudentData(inFile);
gradeCalc.displayGradeAverage(0);
}
public void getStudentData(Scanner inFile)
{
System.out.println("Grade Calculator is getting information...");
System.out.println("One Moment Please");
}
public void displayGradeAverage(int stName)
{
displayedStudentIndex = stName;
String strName = "";
boolean classAvg = studentList[(int)
(totalScore /noOfStudents)].getClassAverage();
stNameTF.setText(StudentList[stName].getFirstName() + " "
+ studentList[stName].getLastName());
stAvgTA.setText(""+StudentList[(int) (totalScore / 3.0)].getStudentAverage());
classAvgTA.setText(""+StudentList[(int) (totalScore /
noOfStudents)].getClassAverage());
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote