Question
complete the implementation of saveMarkInfo and readMarkInfo functions #include #include #include using namespace std; #define SIZE 5 // Max size of the array int count
complete the implementation of saveMarkInfo and readMarkInfo functions
#include
#define SIZE 5 // Max size of the array
int count = 0; // global variable to count student's // mark info added into the array // Define student's info data uisng struct struct student { string name; int coursework, finalExam; };
// Function prototypes. // Only need to complete the implementations of readMarkInfo and // saveMarkInfo functions char chooseYesNo(string); char getGrade(int); int getTask();
void addMarkInfo(student []); void readMarkInfo(student []); // to be called inside main function
void listMarkInfo(student []); void saveMarkInfo(student []); // to be called inside listMarkInfo function
void viewResults(student [], int); void viewReports(student []);
// Start main function ////////////////////////////////////////////// int main() { // use student structure array data to store student's marks info student studs[SIZE]; int task = getTask(); while (task != 6 ) { switch (task) { case 1: addMarkInfo(studs); break; case 2: readMarkInfo(studs); break; case 3: listMarkInfo(studs); break; case 4: viewResults(studs, count); break; case 5: viewReports(studs); } task = getTask(); } return 0; } // End main function ////////////////////////////////////////////////
// Start user defined functions implementations /////////////////////
// function to get yes or no option from user by // pressing 'y' or 'n' character char chooseYesNo(string caption) { char opt = 'x';
while (opt != 'y' && opt != 'n') { cout > opt; } cout
// only 5 levels of grades (A, B, C, D & E) char getGrade(int m) { if (m >= 85) return 'A'; if (m >= 70) return 'B'; if (m >= 55) return 'C'; if (m >= 40) return 'D'; return 'E'; }
// only allow users to choose the option from 1 to 5 int getTask() { int t = 0; cout 6) { cout > t; } cout
// function to add student's marks info from input using keyboard void addMarkInfo(student s[SIZE]) { if (count > s[count].name; cout 70) { cout > s[count].coursework; } cout 30) { cout > s[count].finalExam; } count++; } }
// Need to complete this function to read marks info from // assg4-input.txt file. The marks info data is to be // stored inside (overwrite) the 'studs' (Student struct // type array variable) void readMarkInfo(student s[SIZE]) { cout
// function to list student's marks info stored // inside student struct array variable (studs) void listMarkInfo(student s[SIZE]) { if (count > 0) { cout
// need to complete this function to save marks info entered // by the users into the assg4-input.txt file void saveMarkInfo(student s[SIZE]) { cout
// Function to processs and list student's total marks and grade. // 1. Student's marks info is retrieved from student struct array variable (studs). // 2. The 'array_size' is useful so this function can be reused inside viewReports // function to display students who got total marks less than the average void viewResults(student s[], int array_size) { if (array_size > 0) { cout
// function to generate student's total marks statistic report void viewReports(student s[SIZE]) { int total_all = 0, total, highest, lowest; float avg = 0; if (count > 0) { highest = s[0].coursework + s[0].finalExam; lowest = highest; for (int i = 0; i highest) highest = total; if (total 0 so there is student got marks below the average if (count_below) viewResults(studs_below, count_below); // reuse viewResults function } }
Function: saveMarkInfo 1. Add data 2. Read data 3. List data 4. View results 5. View reports 6. Quit program Enter your choice [1 - 6]: 1 The users may start using the program by adding several student's marks information. Function to support this operation has been completed for you. Student's name: Alice Coursework (-70): 38 Final Exam (-30): 18 1. Add data 2. Read data 3. List data 4. View results 5. View reports 6. Quit program Enter your choice [1 - 6]: 1 Student's name: Brady Coursework (0-70): 47 Final Exam (0-30): 25 Function: saveMarkInfo 1. Add data 2. Read data 3. List data 4. View results 5. View reports 6. Quit program Enter your choice (1 - 6]: 3 No. Name Coursework Final Exam 1. Alice 38 2. Brady save marks info? [y/N]: y save marks info into file: assg4-input.txt 18 25 47 Next, the users may list the previously entered marks information. This operation is supported by listMarkinfo function. This function also ask the users either they want to save the marks information data into the file: assg4-input.txt 1. Add data 2. Read data 3. List data 4. View results 5. View reports 6. Quit program If the user choose 'y' then the saveMarkInfo function is called to run the save file operation. Your first task is to complete the implementation of this particular function. Enter your choice [1 - 6]: 6 Function: save Markinfo - assg4-input - Notepad File Edit Format View Help Brady 47 125 Alice 38 18 This is the example of the assg4-input.txt file content should be produced by the saveMarkInfo the (based on the previous marks info data input) Ln 2, Col 10 100% Windows (CRLF) UTF-8 Function: read MarkInfo 1. Add data 2. Read data 3. List data 4. View results 5. View reports 6. Quit program Enter your choice (1 - 6]: 2 Read marks info from input file: assg4-input.txt This operation will overwrite all data in the array Continue operation? [y]: y The users may quit and then restart the program. Now, if they choose the option no. 2 from the main menu, the program should able to read the input from the assg4-input.txt file by calling the readMarkInfo function (from inside the main function). Your 2nd task is to complete the implementation of this particular function. 1. Add data 2. Read data 3. List data 4. View results 5. View reports 6. Quit program Enter your choice [1 - 6]: 3 Next, the users may list the current data where inputs are taken from the assg4-input.txt file. No. Name Coursework Final Exam 1. Alice 2. Brady Save marks info? [y]: n. 38 47 18 25 Function: read MarkInfo 1. Add data 2. Read data 3. List data 4. View results 5. View reports 6. Quit program Enter your choice [1 - 6]: 2 Read marks info from input file: assg4-input.txt This operation will overwrite all data in the array Continue operation? [y]: y The users may quit and then restart the program. Now, if they choose the option no. 2 from the main menu, the program should able to read the input from the assg4-input.txt file by calling the read MarkInfo function (from inside the main function). Your 2nd task is to complete the implementation of this particular function. 1. Add data 2. Read data 3. List data 4. View results 5. View reports 6. Quit program Enter your choice [1 - 6]: 3 Next, the users may list the current data where inputs are taken from the assg4-input.txt file. No. Name Coursework Final Exam 1. 18 Alice 2. Brady Save marks info? [y]: n. 38 47 25 Function: read MarkInfo 1. Add data 2. Read data 3. List data 4. View results 5. View reports 6. Quit program Enter your choice [1 - 6]: 1 student's name: name: James coursework (0-70): 43 After reading the input data from assg4-input.txt file, the user may continue to add new data interactively from the keyboard. Final Exam (0-30): 22 1. Add data 2. Read data 3. List data 4. View results 5. View reports 6. Quit program Enter your choice [1 - 6]: 3 No. Name Coursework Final Exam The users can list the data which inputs are gathered from the assg4-input.txt file and the keyboard. They can also optionally overwrite the assg4-input.txt file by using this latest list of input data. 1. Alice 2. Brady 3. James Save marks info? [y]: 38 47 43 18 25 22 Function: * 1. Add data 2. Read data 3. List data 4. View results 5. View reports 6. Quit program The rest is the users can do the other operations as listed in the main menu of the program. All have been completely implemented in the program Enter your choice (1 - 6]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