Question: Can someone help me with my code, I'm supposed to enter the test key and have the student.txt file come up in my output with

Can someone help me with my code, I'm supposed to enter the test key and have the student.txt file come up in my output with students names and answers. Here is a copy of my code and the output.

#include #include #include #include #include

using namespace std;

void readDataFromFile(); void calculateResult(); void displayResult(); void removeCharsFromString(string &str); //Name of the file char file_name[20] = "student.txt"; int total_record = 0;

char answer_keys[10];

struct Student { int stud_id; string full_name, answers; char letter_grade; double total_points, avg;

int operator=(const Student& s) { this->stud_id = s.stud_id; this->full_name = s.full_name; this->letter_grade = s.letter_grade; this->answers = s.answers; this->total_points = s.total_points; this->avg = s.avg; return 0; }

}record[50];

void StudentSort() { int i, j; Student check;

for (i = 1; i= 1 && (check.full_name

int main() {

readDataFromFile();

//Promt user for answer key cout > answer_keys[i]; }

calculateResult(); displayResult();

return 0; }

void readDataFromFile() { //File information ifstream ifile; ifile.open(file_name);

total_record = 0;

string line = ""; while (!ifile.eof()) { getline(ifile, line); string id = line.substr(0, line.find(" ")); record[total_record].stud_id = atoi(id.c_str()); record[total_record].full_name = line.substr(line.find(" ") + 1); line = ""; getline(ifile, line); record[total_record].answers = line; total_record++; } if (total_record > 0) total_record--; ifile.close(); StudentSort(); }

void calculateResult() {

cout

for (int i = 0; i

int points = 0; for (int j = 0; j

if (record[i].avg >= 90) { record[i].letter_grade = 'A'; } else if (record[i].avg >= 80 && record[i].avg = 70 && record[i].avg = 60 && record[i].avg

cout

}

void displayResult() //Display {

cout

for (int i = 0; i

cout

for (int i = 0; i

cout

for (int i = 0; i

void removeCharsFromString(string &str) { str.erase(remove(str.begin(), str.end(), ' '), str.end()); }

and this is the error I get.Can someone help me with my code, I'm supposed to enter the

Enter Answer Keys nswer 1 A Answer 2 A Answer 3 A Answer 4 A Answer 5 A Grade Report student ID student Name Answers Total Pts Average Letter Grade record ij. total points record ij.avE etw(8) Runt Debug Assert Program: CAWindowsNSVSTEM32AMSVCP140D.dll File: c: program files (86)Wmicrosoft visual dio 2017M nity vcAtaolsWrmsvcA14.10.25017Minclude xstring Line: 2944 bscript out of string er grade er grade For information on how your program can cause an assertion cout endl setw(4) record ij .stud id K

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!