Question: LAB 1 5 . 9 . 1 : LAB: Student database 0 1 0 Write a program that uses a struct named Student to store
LAB
: LAB: Student database
Write a program that uses a struct named Student to store information about a Student. You will be reading from a text input file into an array size of Student structs. The program will contain the following files:
main.cpp contains the main function for testing the program.
Student.h and Student.cpp represent a classroom student struct, which has three data members:
first name, last name, and GPA.
students, txt Text file with student information
Build the Student struct with the following specifications in the files Student and Student.cpp:
char firstName
char lastName
double gpa;
You may NOT use strings.
Create the following functions Student and Student.cpp:
void loadValuesifstream &inFile, Student studentList int &numStudents; reads from file, populates the array, updates the number of students in the array
void printValuesStudent studentList int numStudents; prints the contents of the array
In main maincpp open the students.txt file and pass to the loadvalues function to read the student data into the array. Then call the printValues function to print out the list of students.
Program input and output:
File input, students txt:
Henry; Nguyen;
Brenda; Stern;
Lynda; Robison;
Sonya;King;
Program output:
tableHenryNguyen,BrendaStern,LyndaRobison,
Notes:
Add the struct definition before the function prototypes! Check out Structs and Array Example, Section
Make sure to have #include main;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
