Java Netbeans Application To Find Out Total, Percentage Of Any Three Subjects.

Q5. Design a GUI application to find out Total, Percentage of any three subjects (Subject marks not more than 100).

Sol:

Create a GUI application as per following screenshot.

Type the following code by double clicking BtnTot, button, below the line that says, ‘// TODO add your handling code here’

//declaring variables

int a,b,c,tot;

//This statement will obtain a numeric value from the textfield.

a=Integer.parseInt(txt1.getText());

b=Integer.parseInt(txt2.getText());

c=Integer.parseInt(txt3.getText());

tot=a+b+c;

//set as text in textfield.

lbltot.setText(tot+””);

 

Type the following code by double clicking BtnPer, button, below the line that says, ‘// TODO add your handling code here’

//declaring variables

int tot,per;

//This statement will obtain a numeric value from the textfield.

tot=Integer.parseInt(lbltot.getText());

per=tot/3;

//set as text in textfield.

lblper.setText(per+””);

 

Output of the above program will be:

Leave a Reply

Your email address will not be published. Required fields are marked *

14 Views
%d bloggers like this: