-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassArray.java
More file actions
53 lines (37 loc) · 885 Bytes
/
Copy pathPassArray.java
File metadata and controls
53 lines (37 loc) · 885 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
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
51
52
53
/**
*
*/
package problemDomain;
import java.util.Scanner;
/**
* @author henryhan
*
*/
public class PassArray {
/**
* @param args
*/
public static void main(String[] args) {
final int ARRAY_SIZE = 4;
int[] numbers = new int[ARRAY_SIZE];
getValues(numbers);
System.out.println("Here are the numbers that you entered.");
showArray(numbers);
}
private static void getValues(int[] array) {
@SuppressWarnings("resource")
Scanner keyboard = new Scanner(System.in);
int size = array.length;
System.out.println("Enter a series of " + size + " numbers.");
for(int i=0; i<size; i++) {
System.out.print("Enter number " + (i+1) + ": ");
array[i] = keyboard.nextInt();
}
}
private static void showArray(int[] array) {
int size = array.length;
for(int i=0; i<size; i++) {
System.out.print(array[i] + " ");
}
}
}