Java snippet to add two numbers given by user

1 min read
Table of contents
import java.util.Scanner;
public class SumOfTwoNumber {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter number 1");
int num1 = scan.nextInt();
System.out.println("Enter number 2");
int num2 = scan.nextInt();
int sum = num1 + num2;
System.out.println("The sum is " + sum);
}
}
0
Subscribe to my newsletter
Read articles from RAJAI TARUN directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
