-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSum.java
More file actions
23 lines (15 loc) · 679 Bytes
/
Copy pathSum.java
File metadata and controls
23 lines (15 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Scanner;
public class Sum{
public static void main(String[] args)
{
int a,b,sum;
Scanner scan = new Scanner(System.in);//Created a object of the Scanner class to use to take inputs from the user
System.out.println("Enter the Number");
a = scan.nextInt();// used the object of the scanner class to to take input nextInt() is a method from the scanner class just like the function from a class in cpp calling it and using it with
System.out.println("Enter the Number");
b = scan.nextInt();
sum = a + b;
System.out.println("Sum is :" + sum);
scan.close();
}
}