WAP to find a sum of two numbers using scanner.
2 years ago
OOP Java
Compile code:
import java.util.Scanner;
public class Sum1{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("Enter the first number: ");
int num1=sc.nextInt();
System.out.println("Enter the second number: ");
int num2=sc.nextInt();
sc.close();
int sum=num1+num2;
System.out.println("The sum of numbers: "+sum);
}
}
Output:
Dipti KC
Jan 8, 2023