This Example will teach you how to make the Calculator programming in java step by step in right way. this is the professional way to do the calculation part.
First Step Create the Variable
int operation;
public void getSum(int operation) { if(txtNum1.getText().length()!=0 && txtNum2.getText().length()!=0) { switch(operation) { case 1: txtResult.setText(""+(Double.parseDouble(txtNum1.getText())+Double.parseDouble(txtNum2.getText()))); break; case 2: txtResult.setText(""+(Double.parseDouble(txtNum1.getText())-Double.parseDouble(txtNum2.getText()))); break; case 3: txtResult.setText(""+(Double.parseDouble(txtNum1.getText())*Double.parseDouble(txtNum2.getText()))); break; case 4: txtResult.setText(""+(Double.parseDouble(txtNum1.getText())/Double.parseDouble(txtNum2.getText()))); break; } } }
Paste the Code side the + Button
operation=1; means go to check case 1
operation=1; getSum(operation);
Paste the Code side the – Button
operation=2; means go to check case 2
operation=2; getSum(operation);
Paste the Code side the * Button
operation=3; means go to check case 3
operation=3; getSum(operation);
Paste the Code side the / Button
operation=4; means go to check case 4
operation=4; getSum(operation);
In this tutorial will teach Laravel 11 Api MVC with Repository Pattern Crud Application step…
In this tutorial will teach Laravel 11 CRUD Application step by step. Laravel 11 CRUD…
in this tutorials we will be talk about how to make a times table in…
In this tutorials will teach How to add two numbers in Laravel 10. (more…)
In this tutorial, we will teach the process of building a full-stack application using Node.js,…
In this tutorial, we will explin you through the process of building a Hospital Management…