Home Java Add two numbers using Java

Add two numbers using Java

1 min read
0
0
611

This tutorial will teach you Input two numbers to calculate and display the total.

 

paste the code inside the + button

   int Num1 = Integer.parseInt(txtNum1.getText());
   int Num2 = Integer.parseInt(txtNum2.getText());
        
   int tot = Num1 + Num2;
        
   txtTotal.setText(String.valueOf(tot));

paste the code inside the – button

int Num1 = Integer.parseInt(txtNum1.getText());
int Num2 = Integer.parseInt(txtNum2.getText());
        
int tot = Num1 - Num2;
        
txtTotal.setText(String.valueOf(tot));

paste the code inside the * button

int Num1 = Integer.parseInt(txtNum1.getText());
int Num2 = Integer.parseInt(txtNum2.getText());
        
int tot = Num1 * Num2;
        
txtTotal.setText(String.valueOf(tot));

paste the code inside the / button

int Num1 = Integer.parseInt(txtNum1.getText());
int Num2 = Integer.parseInt(txtNum2.getText());
        
int tot = Num1 / Num2;
        
txtTotal.setText(String.valueOf(tot));

 

 

Load More Related Articles
Load More By admin
Load More In Java

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also

Employee Working Hours Calculation System using C#.net

Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the f…