Published
- 1 min read
algorithm to add two numbers in java
The solution for this is noted below
algorithm to add two numbers in java
Solution
import java.util.Scanner;
public class Adding {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter number: ");
int num1, num2;
num1 = sc.nextInt();
System.out.print("Enter second number: ");
num2 = sc.nextInt();
System.out.println("The sum of two numbers is "+ (num1 + num2));
}
}
Try other methods by searching on the site. That is if this doesn’t work