How to solve sum in java by taking input from user?


INPUT:-

import java.util.Scanner; 

public class example{

public static void main (String args[]){

Scanner sc = new Scanner(System.in);

int num1,num2,num3;

System.out.println("Enter your first number : ");

num1=sc.nextInt();

System.out.println("Enter your second number : ");

num2=sc.nextInt();

num3 = num1+num2;

System.out.println("Your num1 and num2 sum is : " + num3);

}

}

OUTPUT:-