-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddition.java
50 lines (31 loc) · 922 Bytes
/
Addition.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* @author Ari Danon
* @version 6 Feb 2024
* This Class will demo the Scanner and add two numbers together
*/
//This is where we import classes
import java.util.Scanner;
// class declaration
public class Addition {
// this is the method declaration
public static void main(String[] args){
// Create an instance of scanner
Scanner input = new Scanner(System.in);
// Prompt user for first Integer
System.out.print("Enter the first integer: ");
// Declare integer a
int a;
// Get user input
a = input.nextInt();
// Prompt user for second Integer
System.out.print("Enter the second integer: ");
// Declare b
int b;
//Get user input
b = input.nextInt();
//Add the two
int c = b + a;
//Print the two
System.out.printf("The sum is: %d%n", c);
}
}