You must include 6 subs, one to do each of the following:
Prompt for and read in the answer to the Enter student data? question.
Prompt for and read in the student’s name.
Prompt for and read in the student’s age.
Prompt for and read in the student’s GPA.
Prompt for and read in the file name.
Print to the file at the end of the main program.
I suggest that you declare three arrays, one each to store the student’s name, the student’s age, and the GPA. Element 0 of these three arrays constitutes the data for one student. Element 1 is the data for another student … and so on.
The approach of using several arrays, and using the same element of each for one bigger thing (e.g., a student) is called parallel arrays.
Remember, you can grow an array as the data is read by using the push function.