Design a Java Netbeans GUI applications to calculate bonus and netsalary with if condition

Q11. Design a Java Netbeans GUI applications to calculate bonus and netsalary with if condition.

Criteria Table

Salary Bonus
1-5000 15% of Bonus
5001-8000 25% of Bonus
8001-10000 30% of Bonus
Above 10000 35% of Bonus

Create a GUI application as per following screenshot.

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

int sal;

double bon,nsal;

sal=Integer.parseInt(txtsal.getText());

if(sal>1 && sal<=5000)

bon=sal*.15;

else if(sal>5000 && sal<=8000)

bon=sal*.25;

else if(sal>8000 && sal<=10000)

bon=sal*.30;

else

bon=sal*.35;

lblbon.setText(bon+””);

nsal=sal+bon;

lblsal.setText(nsal+””);

}

OUTPUT:

Leave a Reply

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