Addition of Two Numbers in Java:-
Program:
import java.util.*;
class Add{
public static void main(String args[]){
System.out.println("Enter 1st Number:");
Scanner in = new Scanner(System.in);
int num1 = in.nextInt();
System.out.println("Enter 2nd Number:");
int num2 = in.nextInt();
int sum= num1+num2;
System.out.print("Two Number sum is :"+ sum);
}
}
Output:
PS D:\Learning File\BCA\BCA 3rd Sem\JAVA OOP\AllPraQue> java Add
Enter 1st Number:
5
Enter 2nd Number:
6
Two Number sum is :11
Comments