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

The task is to compute Grade Point Average (GPA) for each of the given number of

ID: 3530243 • Letter: T

Question

The task is to compute Grade Point Average (GPA) for each of the given number of students using arrays. GPA must be based on the number of courses taken, earned credits and grades in a given semester. These courses may vary from one student to another. For example, Joe may take 4 classes, each with 3 hours, whereas, Jill may take 5 classes: 3 with 4 hours and 2 with 3 hours. Grade points are assigned according to the following distribution: Percentages Letter grade Grade Points [93, 100] A 4.00 [90, 93) A- 3.67 [87, 90) B+ 3.33 [83, 87) B 3.00 [80, 83) B- 2.67 [77, 80) C+ 2.33 [73, 77) C 2.00 [70, 73) C- 1.67 [67, 70) D+ 1.33 [63, 67) D 1.00 [60, 63) D- 0.67 [0, 60) F 0.00 Requirements: You must create an Eclipse project named StudentGPA. You must implement using Arrays and Class(es). Each class should have proper instance variables and methods; each method must address a single well-defined mini task. You may directly read the letter grades (and not compute in your program) must use arrays this is a simple java program use only simple libraries

Explanation / Answer

In the above answer change these lines

public class MainPage extends JPanel {


import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;


private JLabel subjectLabel, cHoursLabel, gradeLabel;

private JTextField subject, cHours;

private JButton addSubjectButton, calcGPAButton, clearAllButton;

private JTextArea tArea;

private JComboBox grade;


List<String> gradeArray = new ArrayList<String>();

List<Integer> cHoursArray = new ArrayList<Integer>();

Map<String, Double> grades = new HashMap<String, Double>();


public MainPage() {

this.populateGrades();


setLayout(null);

setPreferredSize (new Dimension(500, 500));

setBackground (Color.orange);


subjectLabel = new JLabel ("Subject Name: ");

subject = new JTextField (33);

subject.addActionListener (new TempListener());


gradeLabel = new JLabel ("Grade: ");

grade = new JComboBox (grades.keySet().toArray());

grade.addActionListener (new TempListener());


// ... THE REST OF YOU CODE ... //

}


private void populateGrades() {

grades.put("A", 4.00);

grades.put("A-", 3.67);

grades.put("B+", 3.67);

grades.put("B", 3.67);

grades.put("B-", 3.67);

grades.put("C+", 3.67);

grades.put("C", 3.67);

grades.put("D", 3.67);

grades.put("D-", 3.67);

grades.put("E", 3.67);

grades.put("F", 3.67);

}


private class TempListener implements ActionListener {

double tCrPoints = 0.00, tCrHours = 0.00, tGPA = 0.00;

String status;


public void actionPerformed(ActionEvent event) {

if (event.getSource() == addSubjectButton) {

// Not sure what you are trying to do here, you are basically setting the 3 arrays identical

// subject.getText() = 1 ==> subjectArray[1,1,1,1,1,1]

// Do not see the point of this at all

/* for (int i=0; i<6; i++) {

subjectArray[i] = subject.getText();

gradeArray[i] = (String) grade.getSelectedItem();

cHoursArray[i] = Integer.parseInt(cHours.getText());

} */


gradeArray.add(grade.getSelectedItem().toString());

cHoursArray.add(Integer.parseInt(cHours.getText()));


tArea.append (subject.getText() + " " + grade.getSelectedItem() + " " + cHours.getText() + " ");

subject.setText("");

cHours.setText("");

}


if (event.getSource() == calcGPAButton) {

for (String grade : gradeArray) {

tCrPoints += grades.get(grade);

}


for (Integer hour : cHoursArray) {

tCrHours += hour;

}


tGPA = tCrPoints/tCrHours;


if (tGPA >= 2) {

status = ("Pass");

} else {

status = ("Fail");

}


tArea.setText("Total Credit Points : " + tCrPoints + " " +

"Total Credit Hours : " + tCrHours + " " +

"Grade Point Average (GPA) : " + tGPA + " " +

"Status : " + status);

}


if (event.getSource() == clearAllButton) {

tArea.setText("");

cHours.setText("");

grade.setSelectedIndex(0);

tCrHours = 0.00;

tCrPoints = 0.00;

}

}

}

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