Count Lowest to Highest.

Q18. Design a Java Netbeans 6.5.1 GUI application having interface as shown below :

 The loop for the frame should print numbers from lowest to highest on the basis of given two numbers, upon clicking at “Count” button.

Sol:

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

 

 

int num1,num2;

num1=Integer.parseInt(jTextField1.getText());

num2=Integer.parseInt(jTextField2.getText());

if(num1<=num2)

for(;num1<=num2;num1++)

jTextArea1.append(num1+” “);

else

for(;num1>=num2;num2++)

jTextArea1.append(num2+” “);

}

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

 

jTextField1.setText(“”);

jTextField2.setText(“”);

jTextArea1.setText(“”);

}

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

 

System.exit(0);

}

Output:

 

 

Leave a Reply

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