I have a problem with my code. We're reading from a file and printing out lines from it depending on what the user enters. When I try to compile it highlights "UI.println(course + room + fName + lName);" and gives the error: int cannot be dereferenced. Anybody know what I'm doing wrong?
public void printSession(){
try{
File exams = new File("examdata.txt");
Scanner scan = new Scanner(exams);
int mainDate = UI.askInt("Which day of the month would you like to view?");
while(scan.hasNext()){
String course = scan.next();
String room = scan.next();
int date = scan.nextInt();
int students = scan.nextInt();
String fName = scan.next();
String lName = scan.next();
if(date.equalsIgnoreCase(mainDate)){
UI.println(course + room + fName + lName);
}
}
UI.println("Done");
}catch(IOException e){
UI.printf("File Failure: %s\n", e);
}
}


Sign In
Create Account

Back to top









