import java.util.*;
import java.io.*;
public class Problem1
{
public static void main( String args[] ) throws Exception
{
// close/reuse this file handle on the next file
BufferedReader infile = new BufferedReader( new FileReader( "student2courseNums.txt" ) );
// you declare all needed ArrayLists and other variables from here on.
ArrayList<String>studentScores = new ArrayList<String>();
while(infile.ready())
{
studentScores.add(infile.readLine());
}
infile.close();
BufferedReader infile1 = new BufferedReader( new FileReader( "courseNum2CourseName.txt" ) );
ArrayList<String>courseName = new ArrayList<String>();
while(infile1.ready())
{
String[] tokens = infile1.readLine().split(" ");
String iD = tokens[0];
ArrayList<String>mirror = null;
{
mirror = new ArrayList<String>(Arrays.asList(tokens[1]));
for( int i=0; i<mirror.size(); ++i)
mirror.set(i, mirror.get(i) + " " + iD);
courseName.addAll(mirror);
}
}
infile1.close();
Collections.sort(studentScores);
for(String line : studentScores)
System.out.println(line);
System.out.println();
Collections.sort(courseName);
for(String course : courseName)
System.out.println(course);
} // END MAIN
I'm trying to print out:
Hector DatabaseManagementSystems AlgorithmDesign AppliedCryptographyNetwork DataCommunicationsComputerNetworks
Jeffy AlgorithmDesign SoftwareEngineering
Johnny IntroAI AIProgramming SoftwareDesignMethodology InterfaceDesignMethodology
Keisha IntroComputerArchitecture IntroCompilerDesign IntroHighPerformanceComputingSystems AdvancedSystemsSoftware DataCommunicationsComputerNetworks
Mario SoftwareEngineering IntroComputerGraphics IntroAI GameDesign
Reddy DatabaseManagementSystems SoftwareEngineering IntroAI DatabaseManagementSystems
Sarada IntroComputerArchitecture IntroCompilerDesign IntroHighPerformanceComputingSystems AdvancedSystemsSoftware DataCommunicationsComputerNetworks
as my final output along with the other bits I already have. If you were to run my program as it is now it would run fine. You would need to do java Problem1 student2CourseNums.txt courseNum2CourseName.txt
The student2CourseNums.txt is:
Hector CS1555 CS1510 CS1653 CS1652
Mario CS1530 CS1566 CS1571 CS1666
Sarada CS1541 CS1622 CS1645 CS1651 CS1652
Reddy CS1555 CS1530 CS1571 CS1555
Johnny CS1571 CS1573 CS1631 CS1635
Keisha CS1541 CS1622 CS1645 CS1651 CS1652
Jeffy CS1510 CS1530
The courseNum2CourseName.txt is:
CS1510 AlgorithmDesign
CS1530 SoftwareEngineering
CS1538 IntroSimulation
CS1541 IntroComputerArchitecture
CS1555 DatabaseManagementSystems
CS1566 IntroComputerGraphics
CS1571 IntroAI
CS1573 AIProgramming
CS1622 IntroCompilerDesign
CS1631 SoftwareDesignMethodology
CS1635 InterfaceDesignMethodology
CS1645 IntroHighPerformanceComputingSystems
CS1651 AdvancedSystemsSoftware
CS1652 DataCommunicationsComputerNetworks
CS1653 AppliedCryptographyNetwork Security
CS1655 SecureDataManagementWebApplications
CS1666 GameDesign
CS1671 HumanLanguageTechnologies
Any idea's how I can get the output I earlier stated along with the output I currently get? I currently get this output by the way:
CS1510 AlgorithmDesign
CS1530 SoftwareEngineering
CS1538 IntroSimulation
CS1541 IntroComputerArchitecture
CS1555 DatabaseManagementSystems
CS1566 IntroComputerGraphics
CS1571 IntroAI
CS1573 AIProgramming
CS1622 IntroCompilerDesign
CS1631 SoftwareDesignMethodology
CS1635 InterfaceDesignMethodology
CS1645 IntroHighPerformanceComputingSystems
CS1651 AdvancedSystemsSoftware
CS1652 DataCommunicationsComputerNetworks
CS1653 AppliedCryptographyNetwork Security
CS1655 SecureDataManagementWebApplications
CS1666 GameDesign
CS1671 HumanLanguageTechnologies

New Topic/Question
Reply



MultiQuote







|