Java Program to Add Two Numbers
In this program, we will take two values from user as input and calculate their sum.
- //Java program to add two integers
-
- import java.util.Scanner;
-
- public class Main {
- public static void main(String[] args) {
-
- Scanner first = new Scanner(System.in);
- System.out.println("Enter first number: ");
- int a = first.nextInt();
-
- Scanner second = new Scanner(System.in);
- System.out.println("Enter second number: ");
- int b = second.nextInt();
-
- int sum = a + b;
-
- System.out.println("The sum is: " + sum);
- }
- }
Output

Solution not working or have any suggestions? Please send an email to [email protected]
Download Android App