When user enters serial number/subject id, the program reads from a bunch of files and finds the corresponding .txt file and displays the name of assignments listed in the .txt file. I'm having a lot of trouble creating the program please help me; this is the code I have come up with.
import java.io.IOException;
import java.util.Scanner;
import java.io.File;
public class prog{
public void prog(){
System.out.print("Enter a serial number.");
Scanner in;
try{
if (I.equals("English07")){
in = new Scanner(new File("English07"));
File f = new File(“C:\Documents and Settings\Administrator\Desktop.txt”);
String I = new String ("English07");
I = in.nextLine();
System.out.println(I);
}
if(II.equals("chemistry07")){
in = new Scanner(new File("chemistry07"));
File f = new File(“C:\Documents and Settings\Administrator\Desktop.txt”);
String II = new String ("chemistry07");
II = in.nextLine();
System.out.println(II);
}
}catch(IOException i){
System.out.println("Error: " + i.getMessage());
}
}
}
-TY
2007-08-04
07:41:28
·
3 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design