Area and perimeter of square
- 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
- Perimeter
- Now we will write the code of area button.
Code for area
- 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 square which is side × side which we have written as a* a where * is sign of multiply.
- Put the result in result text field.
Code for perimeter
No comments:
Post a Comment