Basically I have made a program for school that reads text from a input file using scanner.
The input file it has 60 rows, each row is in the format: lastname, firstname, major, # credits
so the first 3 rows are like:
I have the program reading the file with a while loop, and then a series of IF statements that use a
.equals on a string variable for the students major, and then some if statements to determine which
class each student is in. Then the program is supposed to output in a JPanel, the number of students
in each class, in each of the 3 majors, IS,HIST,BIOL. I have it correctly doing this.
What I need to do now, is to use the random number generator to pick one of the first 25 students in
the text file, as a winner of a prize, and then just have some code displaying it like this in a new pop up
GUI box: [lname], [fname], of the [students major] department has won $1000.
I'm trying to figure out how to add some code to my whlie loop, so that as the file is being read, it stores
the lname, fname, major of the student that corresponds to a number (between 1-25), that I generedated
at the beginning of the program. All my code is a bit long, but I will attach it all if anyone has time to look
through it. But the main code that relates to this is:
I was going to post the whole code, but I can't seem to fine any file type that is accepted for the attachments. I may try to post
it in another message so people can see what I am talking about. Many thanks for any help or pointers.
not sure what a Map is, is it a method or something? My java knowledge is still pretty basic, that big IF statement was the only way I could really think of to determine what class and major each studen was in.
In which case trySet up some Course objects with a recordCredits method, and use the recordCredits method to increment the number of people. Let the number of people be a field of the Course class. Provide methods to allow each course to return its code, how many students there are, etc.