I have to write a program that will write to a random access file called student.dat . In this file will be things like: GPA, Student ID, Name, and the current amount of points they had earned. program should let you initialize the file to one hundred empty records, input the data concerning each student, enable you to list all students, let you delete a record for a student and let you update any information in the file. The student ID number should be the record number.
I have no idea where to start. I know little bits and pieces... like I know that we might need an array... and that we need to be able to write and read from the file. Could please someone help me?
Not 100% sure what you mean by 'initialize with 100 empty records' - what is an empty record? You know there is a student but don't know their name, ID, etc? Somewhat strange.
So first question - is the format of the file something you are given, or are you defining your own format? Assuming the latter, and you choose to store it simply as
<ID>,<Name>,<GPA>,<Points>
(i.e., 112,Tyler Durden,2.1,9001 could be a single record)
I would say the easiest first step is to write (in notepad) a file with 3 or 4 records, and get your program to read and display them. Then get your program to re-write the file with all the same data that you stored in memory. Then allow the user to change the data in memory such that the changes are reflected in the file.
Work at it a bit, pound out some code, and if you can't it working after a few hours we can likely help you out more.
Student ID | Name | Points| GPA
3 | Chris Budda | 290 | 3.24
17 | Alan Hamer | 91 | 2.93
24 | Michael Finn | 121 | 3.97
39 | Meerab Gill | 143 | 2.84
56 | John Power | 18 | 4.00
68 | Eric Driver | 106 | 2.99
77 | Adam King | 110 | 2.25
83 | Derek Eide | 134 | 3.51
Ill see what I can do. I just have no idea where to start off when doing this. Should I start with just getting information to send to a .dat file? Is a .dat file any different than a txt file?