Home Java Add two numbers using Java

Add two numbers using Java

1 min read
0
0
581

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

Laravel 11 CRUD Application

In this tutorial will teach Laravel 11 CRUD Application step by step. Laravel  11 CRUD App…