Write a java program using following details. You are free to make all necessary assumptions. All the assumptions made should be documented.
There are four scientists who need to be ordered according to their smartness (smartest to least smart). There is a text file "smart.txt" in the following format:
Each line has a pair of names, separated by an arbitrary number of white spaces (' '), where the person named by the first element of the pair is smarter than the person named by the second element of the pair. There is no limit to the number of such pairs listed in the file, but the listing would be sufficient to resolve the order of smartness of the four scientists.
Write a java program (ScientistResolver.java) that takes such a file and prints the list of all the distinct scientist names, without duplicates, one per line, ordered according to their smartness, as below.
Secondly, which part are you having trouble with ?
If it's the reading of the file, then you need to look at a Java I/O tutorial.
Once you've read the file you need to parse each line. Look at the String class for some useful methods to do this.
As for the sorting, the simplest way would be to use a List and just move the scientists around in the List based on each line of the file.
I would give you some relevant links, but I can't connect to java.sun.com at the moment. That's a good place to find useful information. [ June 12, 2008: Message edited by: Joanne Neal ]