Output from array file within main class won't terminate - Any help!!
Hi,
Another simple question I think! Why is the output from this main class not terminating in the output window. The main method is calling an array of 10,000 integers from four seperate text files of telephone numbers. Each file is 10,000 integers long.
When I run this main class it outputs the correct answer but simply does not terminate, and continually repeats the same answer.
Code is as follows:
Code:
import simplejava.*;
public class TelephoneApplication_AlgorithmTest
{
public static void main(String[] args) {
NumberListTester internal = new NumberListTester("INTERNAL.TXT");
NumberListTester local = new NumberListTester("LOCAL.TXT");
NumberListTester national = new NumberListTester("NATIONAL.TXT");
NumberListTester international = new NumberListTester("INTERNATIONAL.TXT");
SimpleWriter screen = new SimpleWriter(System.out);
int givenNumber = 83743;
while (givenNumber!=0) {
if (internal.contains(givenNumber))
screen.println("Internal calls only.");
else if (local.contains(givenNumber))
screen.println("Local and internal calls only.");
else if (national.contains(givenNumber))
screen.println("National, Local and Internal Calls only");
else if (international.contains(givenNumber))
screen.println("All calls permitted");
else screen.println("Number not recognised.");
System.out.println("First Search Complete");
}
}
}
Any help really appreciated!! :confused:
Re: Output from array file within main class won't terminate - Any help!!
Hi,
Problem now solved. I was being a bit daft, and setting the int givenNumber to one value, whilst telling it to keep searching if the output was not 0.
Anyway, all works perfectly now.
Have a great weekend!! :WAVE: