Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that reads from a text file containing student records and puts the data into the below parallel arrays. A student record consists

Write a program that reads from a text file containing student records and puts the data into the below parallel arrays. A student record consists of a students netID, followed by that students major, followed by that students GPA. An example of student record is as follows (for simplicity, assume the students netID is an int): 1001 CS 3.8 The program puts the students netIDs in an array called netIDArray. The program puts the students majors in an array called majorArray The program puts the students GPA in an array called gpaArray The arrays are populated in the order the data is read from the file. For example, the first netID read from the file is assigned to the first element of the netIDArray, the second netID read is assigned to the second element of the netIDArray, and so on. The other arrays are populated in the same fashion. Make sure when you read from the file, you store the items in the arrays in the proper order. The program then uses a loop to display the students netIDs, another loop to display the students majors, and another loop to display the students GPAs. All the data is displayed in the order they are in the arrays. Then the program searches the gpaArray for the lowest GPA, displays that GPA, along with the netID and major of the corresponding student. Similarly it searches the gpaArray for the highest GPA, displays that GPA, along with the netID and major of the corresponding student. Finally the program enters a loop where it prompts the user to enter a students netID, searches on that netID, and displays the netID, GPA and major if found, or Not found if not found. The loop is exited when the user enters -1. To test your program, you will use the text file: studentData1.txt which is posted on eLearning. Note however that your code must work for any file which contains student records, where the record contents are arbitrary netIDs (int), arbitrary majors (string) and arbitrary GPAs (double). The number of records is arbitrary, but you can assume it does not exceed 15. You should set the array sizes accordingly. 1. Additional requirements Make sure you meet all the requirements to avoid losing points 1. To complete the assignment, you are required to use only what has been taught in class. If you have prior programming experience, refrain from using more advanced C++ constructs, so all the homework programs can be graded on a consistent basis. 2. Make sure you follow the requirements in the Homework Notes. 3. You are required to implement your program with the following functions that are called in the main() function: searchLowestInArray: takes as arguments an array of double and its size, and returns the subscript of the lowest double in the array. If there are multiple elements which are the lowest value, the function returns the subscript of the last element. searchHighestInArray: takes as argument an array of double and its size, and returns the subscript of the highest double in the array. If there are multiple elements which are the highest value, the function returns the subscript of the last element. searchValInArray: takes as arguments an int value, an array of ints and its size, and returns the subscript of the array element that matches the value. If there are multiple elements which match the value, the function returns the subscript of the first element that matches. Returns -1 if no match This is the pseudocode of part 1: Open the studentData1.txt file Should check for file open failure and exit if error Read from the file and populate the three arrays Display the netIDArray Display the majorArray Display the gpaArray Call searchLowestInArray to find a student with the lowest GPA, and use the info returned by the function to display the lowest GPA, along with the netID and major of the corresponding student Call searchHighestInArray to find a student with the highest GPA, and use the info returned by the function to display the highest GPA, along with the netID and major of the corresponding student Prompt user to enter students netID Loop as long as students netID not -1 Call searchValInArray to search for a student with that netID Print the result of the search: GPA and major of the student with that netID, or Not found Prompt user to enter students netID End loop Close file Part 2 (Additional 15 points) To get credit for this part, your implementation must be flawless. No partial credit will be given. This is the pseudocode of part 2: Prompt user to enter a new netID Loop as long as students netID not -1 and array not full prompt for major and GPA Update the arrays by adding netID, major and GPA to the netIDArray, majorArray and gpaArray arrays, respectively See note below End loop Display the updated netIDArray Display the updated majorArray Display the updated gpaArray Open outData.txt - Should check for file open failure and exit if error Write your name and username in outData.txt Read the updated arrays to calculate and write the CS statistics into outData.txt. Statistics are: Number of CS students Lowest GPA among all CS students, along with the netID of the student(s) who have that GPA Highest GPA among all CS students, along with the netID of the student(s) who have that GPA Close file Note: A value can be added only if the array is not full. To add a value to a partially filled array, you should write the value into the first available element in the array, right after the last value in the array. For example, if an array of size 10 is partially filled with 5 values, to add a value to the array, you should write at subscript 5. Expected Output If you implement the basic version (part 1 only), you can copy and paste from the file 1336-F17-HW8-1- Input-Basic.txt to save on typing. If you implement the extra credit version (part 1 and part 2), you can copy and paste from the file 1336-F17-HW8-1-Input-XtraCredit.txt to save on typing. Part 1 Part 2

outData.txt should have this content after the program has executed

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago