Standard Calculator
1 Create the Form shown in the figure below in NetBeans
button names: b1,b2,b3,b4,b5,b6,b7,b8,b9,b0
2. Right click the button 1 ==> Events ==> Actions then supply the code below
supply the same code in button 1 to the rest of the buttons from 2 to 0 but don't forget to change the property name of each button.
3. Add this method anywhere in your code, as long as it's between the curly brackets of the class
4. Double click your + , * , / , - button and supply the code below in each button
//for addition
String addbutton = bplus.getText();
getOperator(addbutton);
//for subtraction
String minusbutton = bminus.getText();
getOperator(minusbutton);
//for division
String divutton = bdiv.getText();
getOperator(divutton);
//for multiplication
String mulbutton = bmul.getText();
getOperator(mulbutton);
5. Double click the Equal Button and supply the following code:
5. Double click the clear button and supply this code:
total1 = 0;
txtdisplay.setText("");
Enjoy!!!!
No comments:
Post a Comment