Answered step by step
Verified Expert Solution
Link Copied!

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
15.9.1: LAB: Student database
010
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 20) 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
(1) Build the Student struct with the following specifications in the files (Student.h and Student.cpp):
char firstName[101]
char lastName [101]
double gpa;
You may NOT use strings.
(2) Create the following functions (Student.h and Student.cpp):
void loadValues(ifstream &inFile, Student studentList[, int &numStudents); // reads from file, populates the array, updates the number of students in the array
void printValues(Student studentList], int numStudents); // prints the contents of the array
(3) In main ()(main.cpp), 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.
(4) Program input and output:
File input, students . txt:
Henry; Nguyen; 3.5
Brenda; Stern; 2.0
Lynda; Robison; 3.2
Sonya;King; 3.9
Program output:
\table[[Henry,Nguyen,3.5],[Brenda,Stern,2.0],[Lynda,Robison,3.2]]
(5) Notes:
Add the struct definition before the function prototypes! Check out Structs and Array Example, Section 14.4
Make sure to have #include main()=0;
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions