Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started