Subtraction Of Two Numbers in Java Netbeans 6.5.1.

Q2. Design a Java Netbeans 6.5.1 GUI application to find out subtraction of two numbers?

Sol:

Create a GUI application as per following screenshot.

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

/declaring variables

int x,y,z;

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

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

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

z=x-y;

//set as text in textfield.

lbladd.setText(z+” “);

 

Output of the above program will be:

Leave a Reply

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

%d bloggers like this: