Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
523 views
in Computer by (41.5k points)
closed by

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:

Percentage Grade
>=90 A+
>=80 & <90 A A
>=70 & <80 B
>=60 & <70 C
>50 & <60 D
<50 F

The 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.

1 Answer

+1 vote
by (47.1k points)
selected by
 
Best 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);

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...