Question
Please use c++ write a program! 1.Write a struct called StudentNode that will be used in a linked list. StudentNode should allow the program to
Please use c++ write a program!
1.Write a struct called StudentNode that will be used in a linked list.
StudentNode should allow the program to track the following characteristics about students: name, age, major and gpa.
2.Using the struct in the previous item, write a function that reads from an input file (inFile.txt) and creates the linked list using StudentNode. The sample of the input file is shown below. The input file is only used in this function and should NOT be passed in as a parameter. The code should be written such that each new node is added to the front of the list. Be sure to use the proper parameters and return type. Assume all necessary pre-processor directives, namespace, the StudentNode struct and header information is contained in the header file MyHeader.h. No need to include comments.
Format for inFile.txt
John Smith 20 Math 3.5
Anna White 19 English 3.2
Paul Johnson 18 Physics 3.7
3.Using the struct in item 1, write a function that searches the linked list created in the previous item for one instance of a student. The student name will be used as the search element to find the StudentNode. Be sure to use the proper parameters and return type. Assume all necessary pre-processor directives, namespace, the StudentNode struct and header information is contained in the header file header.h. No need to include comments.
4.Write a function that outputs the entire linked list created in the item 2. The output should be formatted as a table where each students information is output in a separate line. Be sure to use the proper parameters and return type. Assume all necessary pre-processor directives, namespace, the StudentNode struct and header information is contained in the header file header.h. No need to include comments.
5.Write a function that removes the node at the front of the linked list created in the item 2. The function should output the students information from the node being removed. Be sure to use the proper parameters and return type. Assume all necessary pre-processor directives, namespace, the StudentNode struct and header information is contained in the header file header.h. No need to include comments.
6.Write a function that calculates and returns the average gpa for all students in the linked list created in the item 2. Be sure to use the proper parameters and return type. Assume all necessary pre-processor directives, namespace, the StudentNode struct and header information is contained in the header file header.h. No need to include comments.
Create a small main program that calls all functions above and use it as testing for your functions. Please include at least 5 records in the input file. There is no need for documenting your code in this exercise.
main.cpp
header.h (contains struct definition and function prototypes)
functions.cpp - (contains function definitions)
Example Output:
Name Age Major GPA
Paul Johnson 18 Physics 3.7
Anna White 19 English 3.2
John Smith 20 Mathematics 3.5
Student Found:
Anna White 19 English 3.2
Front Node Deleted:
Name Age Major GPA
Paul Johnson 18 Physics 3.7
Updated Student List:
Name Age Major GPA
Anna White 19 English 3.2
John Smith 20 Mathematics 3.5
GPA: 3.35
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