| 1. |
The grade is calculated depending on the percentage of mark in five subjects as English (txtEng), Accounts (txxtAcc), Business Studies (txtBst), Informatics Practices (txtInf) and Economics (txtEco). The grade will be calculated as follows:PercentageGrade>=90A+>=80 & <90 AA>=70 & <80B>=60 & <70C>50 & <60D<50FThe following is the screen used to calculate student grade:Enter roll number, name and five marks in respective text boxes and do the following: (i) Write the code for Calculate Total, percentage & Grade button (named as cmdCalc) to calculate total (txtTotal), Percentage (txtPer) and grade (txtGr). Also display the same in respective text boxes. (ii) Write the code for Clear button (named as cmdClear) to clear all the textbox contents. (iii) Write the code for exit button (named as cmdExit) to close the application. |
|
Answer» 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); |
|