Learn To Make Calculator In Java NetBeans

I Friends Welcome back to The Enchanting Team
Today I will tell you How to Make a Calculator in Java NetBeans.
............
If you Want To Watch Video On this You Can Watch Here (This) 
So You can Watch It. 
So Lets Start Theory on this. 
1. Firstly You have make a New Project
2. So while creating the project 
    first you should set the name of your project.
3. And after this uncheck the main class option      given below the screen.
4. Then as a project has been created,  on the        left side of your screen right click on your          project name and clock on new and choose      Jframe form.
5. So its a layout of your project now you have       design your calculator.
6. For designing you firstly choose label and         name it calculator as heading.

7. After this select and drag one more label           name it number 1 and then  one more label       and name it number 2. 
8. In the front of the number 1 and number 2         you need to drag textfield and edit its text           and make it blank.
9. Now right click on the first text field and             click on the change variable name and               change it to  "val1" and and then right click         on the second text field and name it val2. 
10. Now add one more text field for result.
11. Now set it according to you as it's your               design & change its variable name to                   "result" . 
12. Now drag a  button and name it to                        "calculate". 
13. Now double tap on the calculate button             and enter to the backend of the calculator.         (Coding Part). 
14. Enter this code after the comment / / to do        add your code here. 
15. And yes be careful of small and capital               letters.
The Code is :
--------------------
int a = Integer.parseInt(val1.getText()) ;
int b = Integer.parseInt(val2.getText()) ;
int c = a + b
result.setText(" " + c) ;
--------------------

By adding this code your calculator will only do the function of addition.
For multiplication division subtraction and all you have to add more buttons to your to your project's to your designing panel as +, -, /and x. 
After adding The Other buttons now you have to add this code in all these buttons code area and the change you have to made is  in... int c  = a - b or a * b or a/b. 


So here our calculator has been created thank you very much. 
You can  Leave Comments for any doubt or other purpose.
~Utkarsh Vaishnav
The Enchanting Team 







Comments

Post a Comment

Popular posts from this blog

Obtain principal amount and time and then calculate simple interest as per following specification if the principal is greater than or more than Rs. 10000the rate of interest is 6% otherwise it is 5%

Intro To site