Use the following structure for problem 1. struct student{ string name; int id; float mark; }; Declare
Question:
Use the following structure for problem 1. struct student{ string name; int id; float mark; }; Declare an array named studentArray of the structure type shown above, the size of the array is limited to maximum 100. The main() function handles all interactions with the user and other functions: It displays an appropriate welcoming message introducing the program. Calls a function named readFile() which opens the text file grades.txt for reading and stores all of the students details from the file to an array named studentArray. The grades.txt has three columns, first column contains name, second column contains id and third column contains mark. The readFile()function has two parameters: one for receiving the file variable and one for the array, both receiving arguments passed by reference. It then repeatedly calls the menu() function to display user options, get the user selection returned by the menu() function, use a switch statement to process user request by calling appropriate function(s) It displays the result with an appropriate message after processing user request. It displays a goodbye message when the user selects the Quit option from the menu and terminates the program. The menu() function has no parameters. When called, it displays a menu of 8 options allowing the user to select one and returns this option to the calling main()function. The options displayed should be: (1) Display students’ details (2) Calculate average of all students’ marks (3) Sort the students’ details (4) Search for a particular student’s mark (5) Find maximum (6) Add new student to the record (7) Quit program Option (1) will use a function called displayStudents()called from the main()to display the contents of the studentArray array on the screen in an appropriate format. The displayStudents() function has two parameters: the array and the size of the array. Option (2) will use a function called calculateAverage() which is designed to calculate the average value of all marks in studentArray and return the result to the main() function which will then display it with an appropriate message. This function also has two parameters: the array and the size of the array. Option (3): Ask if the user wants to sort the students’ details with respect to either name or marks. Call appropriate functions to do the same. Option (4) is to search for a particular student’s mark. The function should have three parameters, array, size and the name (a string variable) that the user searching for. This function returns the index of the array if it is found otherwise it returns -1. Display all the details of that student in main function. User should have the options to use either linear search or binary search. Option (5) will use a function called findMaximum()which is designed to find the largest value of all marks in studentArray and return the result to the main() function which will then display it with an appropriate message. This function has two parameters: the array and the size of the array. Option (6) will first use a function called updateFile() which will open the file in append mode, prompt the user for new student’s name, id and mark, and then write the new data at the end of the file using the same format as the original file. It will then the call the readFile()function used in the beginning of the program again to read the contents of the updated file and repopulate the studentArray. Option (7) will terminate the program after displaying an appropriate goodbye message.
Statistics for Business and Economics
ISBN: 978-0132930192
8th edition
Authors: Paul Newbold, William Carlson, Betty Thorne