Java Program to Sum of Two Value


-

-

Example:

Copied
import java.util.Scanner;

public class SumTwoValues {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		System.out.println("Enter first number: ");
		String num1 = scanner.nextLine();
		// getting value from user

		System.out.println("Enter second number: ");
		String num2 = scanner.nextLine();

		int nummber1 = Integer.parseInt(num1);
		int nummber2 = Integer.parseInt(num2);

		int sum = nummber1 + nummber2;

		System.out.println("Sum of two numbers: " + sum);
	}
}

Output:

Enter first number: 10
Enter second number: 20
Sum of two Numbers: 30