Hey, I posted this problem a few days ago, and have been making some progress on it, but I am having a problem when trying to enter in the names. The program is to act like a phonebook, and will take an array of names and numbers, 1000 of them.
If I enter these names and numbers into CMD myself it is fine and will keep going, it is only when I CTRL Z out of the program that it gives me an IO exception error about readInt.
Since the lecturer will be using this program via IO redirect, it should be able to take files, but when I redirect it, I get the error immediatly, and I really don't know what is causing it.
It is all wrote in Java by the way.
Cheers for any help.
[code]class Person
{
private String surname;
private String forename;
private int phonenum;
void getPerson()
{
surname = Console.readToken();
forename = Console.readToken();
phonenum = Console.readInt();
System.out.println(forename + ", " + surname + " " + phonenum);
}
}
class Population
{
Person[] phonebook = new Person[1000];
void getPopulation()
{
for(int i = 0; i < 1000; i++)
{
phonebook[i] = new Person();
phonebook[i].getPerson();
}
}
void printPopulation()
{
while(!Console.endOfFile())
{
for(int i = 0; i < phonebook.length;i++)
{
System.out.println(i);
}
}
}
}
class Directory //This is the main method
{
public static void main(String[] args)
{
System.out.println("Please enter a first name, last name and phone number to store in the phonebook");
Population pop = new Population();
pop.getPopulation();
}
}
[/code]
Can a mod delete this please? Just updated the other thread. Cheers
Sorry, you need to Log In to post a reply to this thread.