Project folder: ….\Source_XII\Practice Papers\SGrade
(i) To calculate Grade, double click on the Calculate Total, Percentage and Grade button (cmdCalc).
Notice that a cmdCalcActionperformed event handler appear with a
//TODO marker line. Write the following lines:
Int R, eng, acc, bst, inf, eco, tot; // Marks and total
Float per;
String Name, Gr=” “;
R = Integer.parseInt(txtRoll.getText());
eng = Integer.parseInt(txtEng.getText());
acc = Integer.parseInt(txtAcc.getText());
bst = Integer.parseInteger(txtBst.get.Text());
inf = Integer.parseInteger(txtInt.getText());
eco = Integer.parseInteger(txtEco.getText());
// Total mark
tot = eng + acc + bst + inf + eco;
// Percentage
per = tot / 5;
if (per >= 90)
Gr = “A+”;
else if (per >= 80 && per < 90)
Gr = “A”;
else if (per >= 70 && per < 80)
Gr = “B”;
else if (per >= 60 && per < 70)
Gr = “C”;
else if (per >= 50 && per < 60)
Gr = “D”;
else if (per < 50)
Gr = “F”;
// Displaying total, percentage and grade
txtTotal.setText(Integer.toString(tot));
txtPer.setText(Float.toString(per));
txtGr.setText(Gr);
(ii) Double click on the clear button, Notice that a cmdClearActionPerformed event handler appears with
a // TODO marker line. Write the following lines:
txtName.setText(“”);
txtRoll.setText(“’);
txtEng.setText(“”);
txtAcc.setText(“”);
txtBst.setText(“”);
txtInf.setText(“”);
txtEco.setText(“”);
txtTotal.setText(“”);
txtPer.setText(“”);
txtGr.setText(“”);
(iii) Double click on the Exit button. Notice that a cmdExitActionPerformed event handler with a //TODO marker line appears. Write the following line,
System.exit(0);