btnCalculate.addActionListener(new ActionListener)() {

public void actionPerformed(ActionEvent e) {
double recitation = Double.parse
Double(txtRecitation.getText());
double review = Double.parseDouble(txtReview.getText());
double homework = Double.parseDouble(txtHomework.getText());
double participation = Double.parseDouble(txtParticipation.getText());
double quizzes = Double.parseDouble(txtQuizzes.getText());
double prelim = Double.parseDouble(txtPrelim.getText());
double midterm = Double.parseDouble(txtMidterm.getText());
double finals = Double.parseDouble(txtFinals.getText());

double classStanding = (recitation*0.1)+(review*0.3)+(homework*0.1)+(participation*0.1)+(quizzes*0.4);
double termGrade = classStanding*2 + (prelim+midterm+finals)/3;
double generalAverage = (prelim*0.3)+(midterm*0.3)+(finals*0.4);
txtResult.setText("Class Standing: " + classStanding + "\nTerm Grade: " + termGrade + "\nGeneral Average: "+ generalAverage);

if(generalAverage >=75) {
txtRemarks.setText("Passed");
}else {
txtRemarks.setText("Failed");
}

}
}
Need Assistance I have Multiple Markers on the First Line and Third Line

User Icon for Explain Bot Explain Bot answered
11 months ago

In the given code snippet, there are two lines with multiple markers: the first line where the `addActionListener` method is called, and the third line where the variables are assigned values.

First line explanation:
- `btnCalculate.addActionListener(new ActionListener)()`: This line sets up an action listener for the `btnCalculate` button. An `ActionListener` interface is implemented and passed as an argument to the `addActionListener` method. The double parentheses `()` at the end of the line are incorrect and should be removed.

Corrected first line:
```java
btnCalculate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// ActionListener code goes here
}
});
```

Third line explanation:
- `double recitation = Double.parse`: This line starts the assignment of the `recitation` variable, but it seems to be incomplete. It should be followed by `.Double(txtRecitation.getText());` to parse the value from the `txtRecitation` text field and assign it to `recitation`.
- The same pattern is followed for the `review`, `homework`, `participation`, `quizzes`, `prelim`, `midterm`, and `finals` variables.

Corrected third line:
```java
double recitation = Double.parseDouble(txtRecitation.getText());
double review = Double.parseDouble(txtReview.getText());
double homework = Double.parseDouble(txtHomework.getText());
double participation = Double.parseDouble(txtParticipation.getText());
double quizzes = Double.parseDouble(txtQuizzes.getText());
double prelim = Double.parseDouble(txtPrelim.getText());
double midterm = Double.parseDouble(txtMidterm.getText());
double finals = Double.parseDouble(txtFinals.getText());
```

After making these corrections, your code should work fine.