-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraySelection.java
More file actions
26 lines (20 loc) · 943 Bytes
/
ArraySelection.java
File metadata and controls
26 lines (20 loc) · 943 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
import java.io.*;
public class ArraySelection {
public static void main (String[] args) throws IOException {
//create our buffer and prompt user for values
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter your Values: ");
//read our values and store them in an Array sparated by spaces
String[] inputValues = bufferedReader.readLine().split(" ");
//create a new array which we will use to store our input values after we have parsed them into integers
double[] arr = new double[100];
//loop through our inputValues array , parse the data and push it into the new array
for (int i=0; i < inputValues.length; i++){
arr[i] = Double.parseDouble(inputValues[i]);
//check if the data stored at each index is <= 10
if (arr[i] <= 10) {
System.out.println("arr["+i+"]= "+arr[i]);
}
}
}
}