Using jGrasp and the Software Development Kit, write a program in response to the following prompt:
Design a GUI program to find the weighted average of four test scores. The four test scores and their respective weights are given in the following format:
testscore1 weight1
…
For example, the sample data is as follows:
75 0.20
95 0.35
85 0.15
65 0.30
The user is supposed to enter the data and press a Calculate button. The program must display the weighted average.
Remember to follow proper form and design in your response.
this is what i came up with but get the errors
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.util.Scanner;
public class TestScores
extends JFrame
75 0.20
95 0.35
85 0.15
65 0.30
{
private JLabel blankoneL, blanktwoL, blankthreeL,scoreL, weightL, oneL, twoL, threeL, fourL, averageL;
private JTextField oneTF, twoTF, threeTF, fourTF, woneTF, wtwoTF, wthreeTF, wfourTF, averageTF;
private JButton calculateB,exitB;
private CalculateButtonHandler cbHandler;
private ExitButtonHandler ebHandler;
private static final int WIDTH =600;
private static final int HEIGHT=400;
public TestScores()
//Making labels for the GUI
{
blankoneL=new JLabel (“”);
blanktwoL=new JLabel(“”);
blankthreeL=new JLabel(“”);
scoreL=new JLabel (“Score”,SwingConstants.CENTER);
weightL=new JLabel (“weight”, SwingConstants.CENTER);
oneL=new JLabel(“Test score #1:”,SwingConstants.RIGHT);
twoL=new JLabel (“Test score #2:” ,SwingConstants.RIGHT);
threeL=new JLabel (“Test score #3:”,SwingConstants.RIGHT);
fourL=new JLabel (“Test score #4:”,SwingConstants.RIGHT);
averageL=new JLabel (“Test score average:” ,SwingConstants.RIGHT);
//Making user input fields
oneTF=new JTextField(5);
twoTF=new JTextField(5);
threeTF= new JTextField(5);
fourTF= new JTextField(5);
woneTF= new JTextField(5);
wtwoTF= new JTextField(5);
wthreeTF= new JTextField(5);
wfourTF= new JTextField(5);
averageTF= new JTextField(5);
//Making a CTA button to get the average
calculateB= new JButton(“Calculate”);
cbHandler=new CalculateButtonHandler();
calculateB.addActionListener(cbHandler);
//Making an exit button
exitB=new JButton(“Exit Program”);
ebHandler=new ExitButtonHandler();
exitB.addActionListener(ebHandler);
setTitle (“Weighted Average Test Scores”);
Container pane = getContentPane();
pane.setLayout(new GridLayout(7,3));
pane.add(blankoneL);
pane.add(scoreL);
pane.add (weightL);
pane.add (oneL);
pane.add (oneTF);
pane.add (woneTF);
pane.add (twoL);
pane.add (twoTF);
pane.add (wtwoTF);
pane.add (threeL);
pane.add (threeTF);
pane.add (wthreeTF);
pane.add (fourL);
pane.add (fourTF);
pane.add (wfourTF);
pane.add (averageL);
pane.add (averageTF);
pane.add (blanktwoL);
pane.add (calculateB);
pane.add (blankthreeL);
pane.add (exitB);
setSize(WIDTH,HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
private class CalculateButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e)
{
double one, wone, two,wtwo, three, wthree,four,wfour, ave;
DecimalFormat twoDigits=new DecimalFormat(“0.00”);
one=Double.parseDouble(oneTF.getText());
wone=Double.parseDouble(woneTF.getText());
two=Double.parseDouble(twoTF.getText());
wtwo=Double.parseDouble (wtwoTF.getText());
three=Double.parseDouble (threeTF.getText());
wthree=Double.parseDouble (wthreeTF.getText());
four=Double.parseDouble (fourTF.getText());
wfour=Double.parseDouble (wfourTF.getText());
ave=(one*wone+two*wtwo+three*wthree+four*wfour)/(wone+wtwo+wthree+wfour);
averageTF.setText(“”+twoDigits.format(ave));
}
}
private class ExitButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
}
}
}
this is the error
—-jGRASP exec: javac -g TestScores.java
TestScores.java:14: error: ‘{‘ expected
extends JFrame
^
1 error
—-jGRASP wedge2: exit code for process is 1.
—-jGRASP: operation complete