Average Of Three Numbers in Java Netbeans 6.5.1.

Q3. Design a Java Netbeans GUI application to find out average of three numbers?

Sol:

Create a GUI application as per following screenshot.

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

//declaring variables

int x,y,z,a;

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

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

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

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

a=(x+y+z)/3;

//set as text in textfield.

lblavg.setText(a+” “);

 

Output of the above program will be:

Leave a Reply

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

22 Views
%d bloggers like this: