Question: This is a C++ Program I need help with. My code is below and it is incomplete. It compiles, but doesn't display everything I need

This is a C++ Program I need help with. My code is below and it is incomplete. It compiles, but doesn't display everything I need it to. Please fix my code. C++ Program Help (Learning Goals)

Functions

C++ structs (records).

Arrays of structs.

Filestreams.

Documentation of program.

A 20 question multiple choice test was given to a group of students. The possible responses are a, b, c, or d. The maximum size of the class is 35. However, less than 35 students may have taken the test.

An input file has been created that contains the following:

1st line: The answer key consists of 20 lower case letters that represent the correct answers to the exam. There will be no blank spaces between the letters. Example: abcdabcdabcdabcdabcd

2nd line - last line: Each line will start with an ID# (int), followed by the first and last names of a student (names will be separated by at least one blank space). The names may be in a mixture of upper and lower case letters. The names will be followed by at least 1 blank space and then that student's responses to the test questions will be provided. There will not be any blank spaces between the responses, but they may be in a mixture of upper and lower case letters. An upper case letter should be considered correct if it matches the lower case equivalent in the key. Example: 63 biLL jOnEs aBcdAbCDabDcabDDABCD

NOTE: The key will consist of exactly 20 characters. However, the student responses may consist of more or less than 20 characters. Assume that the first 20 characters in a student response correspond to the 20 test questions. In other words, if a student only provides 15 answers, then the last 5 questions are wrong. If a student provides 25 answers, the last 5 responses should be ignored.

A second input file contains several integers that are supposed to be the ID#s for some of the students in the class.

Create a C++ program that will

interactively prompt for and read the name of the first input file (with key and student data) and use a filestream variable to represent the file

read the data from the input file and store the student information (ID#s, names, test answers) into an array of structs, counting the students as the data is read

reformat the names into a more conventional form

use the key to grade the exams and store each student's score in the array

interactively prompt for and read the name of an output file

write the following to the specified output file (separate each section with a blank line to improve readability)

a report that displays the names of the students (alphabetically by last name) along with their ID#s and test scores (see formatting specifications and samples below)

a report that displays the class standings with ID#s and test scores (in descending order) (see formatting specifications and samples below) the standings report should include

the number of students who took the test with a label (maximum class size is 35)

the class average (2 digits to right of decimal)

the median (middle value or average of middle values if there are an even number of students, 2 digits to right of decimal)

interactively prompt for and read the name of the second input filewrite an appropriate message to indicate the start of the second input file processingwrite the test key to the output file (with label) read each integer, if it matches an ID# in the student array, write the student's name, test score, and test answers (you may reformat the test answers if you wish) with labels to the output file

if the integer does not match an ID# in the array, write an error message that includes the invalid ID# to the output file

Grading a Test Each of the questions on the test is worth 5 points. The test score is the # of correct responses multiplied by the point value of a question.

Assumptions

The first input file will not be empty. Each line in the file will be terminated by a linefeed (' '). It will be formatted as described above.

The second input file will not be empty. Each integer will be separated by whitespace. The last line in the file will be terminated by a linefeed (' ').

ID#s will be between 1 and 99.

The length of a name (first or last) will be 10 characters or less, for formatting purposes.

Requirements

The program MUST make use of functions (at least 5 meaningful functions in addition to main).

The program MUST CREATE A STRUCT DATA TYPE TO STORE STUDENT DATA AND THEN DECLARE AN ARRAY OF STRUCTS.

The program MUST PASS PARAMETERS to communicate values. No global variables are allowed.

No goto statements may be used.

Program must make use of filestream variables to represent the input and output files. Each input file may only be read one time.

When prompting for file names, the required order is: 1st input file, output file, 2nd input file.

Failure to adhere to the 6 previous requirements will result in up to a 60% deduction of assignment's point value.

Average and median (if even number of students) should be displayed with 2 digits to right of decimal.

For first report, right justify ID#s and test scores. Left justify names. Display names: last,first.

For second report (class standings), right justify ID#s and scores.

Program must include preprocessor directives for all header files used.

Program must use a static array (do not use a variable for the size of the array).

Write your own code - reread the CS 135 academic integrity policy (see syllabus) if necessary.

Test your program adequately! Documentation When the program compiles and runs correctly, add the following documentation (comments) to your source file (.cpp file).

At the start of the program file,Place a comment with your name, lecture section#, and assignment # at the beginning of the file.List the expected input to the program. Be specific. Describe the content of any input files. List the expected output of the program. Be specific. (If the input values are supposed to be displayed, include them in the output list.)

Struct declaration - each member (field) must be adequately described with a comment.

When a named constant and/or major variable is declared, provide a meaningful description of what it represents in the program.

For each function, clearly state what will be passed into the function and what will be passed out or returned by the function. Document important local variables. DO NOT USE SSTREAM, ALGORITHM, LIMIT IN YOUR PROGRAM.

Sample terminal session: This is a C++ Program I need help with. My code is Here is my code. It is incomplete and needs to be fixed:

#include #include #include #include #include

using namespace std;

const int MAX = 35; const int N = 25;

struct studentInfo { string first, last; //student's first and last name int idNum; //student's ID#

};

void get_data(studentInfo[], int&); //takes in student last name, first name, and ID number. void fixstring(string&); //Reformats the string of last names and first names. void bubblesortOne(studentInfo[], int); //sorts the names of students in alphabetical order. void print_roster(studentInfo[], int); //prints things int main() { studentInfo theClass[MAX]; //array to store student information int n; /umber of students in the class get_data(theClass, n); //goes to get_data function bubblesortOne(theClass, n); //goes to bubblesort function for sorting names. print_roster(theClass, n); //goes to print roster function to print things. return 0; }

void get_data(studentInfo theClass[], int& n) { string filename; /ame of input file ifstream in; //input file cout > filename; n = 0; //Not sure what this does.

in.open(filename.c_str());

in >> theClass[n].idNum; while(in) { in >> theClass[n].last >> theClass[n].first; fixstring(theClass[n].last); //initializes fixing the string of last name fixstring(theClass[n].first); //initializes fixing the string of first name n++; in >> theClass[n].idNum; } in.close(); // Goes back to main to work on bubblesort }

void fixstring(string& word) { int wLen = word.length(); //declares word length (of the string) word[0] = toupper(word[0]); for (int i=1; i

void bubblesortOne(studentInfo list[], int n) { int i; int j; studentInfo temp; for (i=0; i list[j+1].last) { temp = list[j]; list[j] = list[j+1]; list[j+1] = temp; } //Goes back to main after sorting. }

void print_roster(studentInfo list[], int n) { cout

keys] more first five abcdabcaabca abca abca 23 boNNie jonEs ABCD abcaAECDabocaAECD 71 Amy 10 mAttHet ADame 31 BarBarA mARIIN3on ABCDABCDABCDABCDABab 19 jENNIFER schwarTz aabbcccaabca abca abca 56 lArrY black ABCDABCDABCDABCDaB keys] more second five 13 10 19 keys]$ g assign 05-opp keys] Enter f first input file first fi Enter the name of the output file fi Enter of nd input file cond fiv keys] more fiv ID SCORE NAME Adame,M at ther 10 15 Black, Larry 95 Jones, Bonnie 100 artinson, Barbara. 31 90 3chnrartz, Jennifer 19 75 3mith, Army 71 75 CLA 33 3TANDING ID 3CORE 100 95 31 90 19 75 71 75 10 15 of students: Claes Av 75.00 erage edian core 2.50 ENT SEARCH FILE PROCE33ING BEGI est key abcdabcaabca abca abca ID Name: Larry Black 95 abcdabcaabca abcaab est responses student ID 13 is valid ID 10 atther Adams 15 Test responses EEEEEEEEE EE ID 19 Name: Jennifer 3chrartz 75 aabbcccaabca abca abca est responses student ID 5 is valid

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!