Hi I have a program that I am to write that is suppose to read from a text file. I am suppose to assume no more than 100 item and terminate after by -1. have to read and store the data. I have to write a method to print the array without showing the null elements, and I need to add a method that will search the string in the array if it can't be find i need to write an error message if the search occurred more than one i am to return an array to show all the corresponding array indexes of the string location. I am also suppose to invoke the print array method. then i have to search the array for a item in it.
here is the txt file here
Able
Baker
Charlie
Dog
Easy
Fox
George
How
Int
Jig
King
Love
Mike
Negative
Option
Peter
Jig
Queen
Roger
Sugar
Tare
Uncle
Victor
William
X-ray
Jig
Yolk
Zebra
<<EOD>>
There are 28 data items
This is my code so far
public static void main(String[] args) {
Scanner inFile = new Scanner(new File (""));
//String array declared created and
String[] sArray;
sArray = new String[100];
String searchValue = "", index;
Scanner inFile = new Scanner (new File(""));
for (int i = 0; i < sArray.length; i++){
sArray[i] = inFile.next();
}
System.out.println("Enter a)
index = binarySearch(sArray, searchValue);
if(index != -1) {
System.out.println("Found at index: " + index);
}
else {
System.out.println("Not Found")
}