Area and perimeter of rectangle
- Open netbeans and make new application.
- Open jFrame component and put the other components from pallet like given below:
- We have kept two buttons:
- Area
- Now we will write the code of area button.
- Code is given below:
- Here we have taken double method instead of integer because it is capable to work with higher numbers as well as decimals.
- Declear variable.
- Connect first text field.
- Put the formula of area of rectangle which is length × bredth which we have written as a × b where * is sign of multiply.
- Put the result in result text field.
Code for area
Code for perimeter
No comments:
Post a Comment