June 2017
Beginner
1296 pages
69h 23m
English
... i++) { // populate array
27 data[i] = 10 + generator.nextInt(90);
28 }
29
30 System.out.printf("%s%n%n", Arrays.toString(data)); // display array
31
32 // get input from user
33 System.out.print("Please enter an integer value (-1 to quit): ");
34 int searchInt = input.nextInt();
35
36 // repeatedly input an integer; -1 terminates the program
37 while (searchInt != -1) {
38 int position = linearSearch(data, searchInt); // perform search
39
40 if (position == -1) { // not found
41 System.out.printf("%d was not found%n%n", searchInt);
42 }
43 else { // found
44 System.out.printf("%d was found in position %d%n%n",
45 searchInt, position);
46 }
47
48 // get input from user
49 System.out.print("Please enter an integer value (-1 to quit): ");
50 searchInt ...