-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddTwoNumbers.java
More file actions
24 lines (18 loc) · 860 Bytes
/
AddTwoNumbers.java
File metadata and controls
24 lines (18 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.util.Scanner;
class AddTwoNumbers {
public static void main(String[] args) {
// Creating a Scanner object to read input from the user
Scanner sc = new Scanner(System.in);
// Declaring two integer variables to store user input
int firstNumber;
int secondNumber;
// Prompting the user to enter the first number
System.out.println("Enter first number");
firstNumber = sc.nextInt(); // Reading first integer input
// Prompting the user to enter the second number
System.out.println("Enter second number");
secondNumber = sc.nextInt(); // Reading second integer input
// Displaying the sum of the two numbers
System.out.print("The addition of numbers is " + (firstNumber + secondNumber));
}
}