Question
#include #include #include #include using namespace std; const int MAX_CLASS_SIZE = 100; const int MAX_NUMBER_OF_ASSIGNMENTS = 100; // do not change these prototypes. Add your
#include
#include
#include
#include
using namespace std;
const int MAX_CLASS_SIZE = 100;
const int MAX_NUMBER_OF_ASSIGNMENTS = 100;
// do not change these prototypes. Add your code to the function definitions below
void Read_Grade_File(string names[MAX_CLASS_SIZE][2], int scores[MAX_CLASS_SIZE][MAX_NUMBER_OF_ASSIGNMENTS], int *number_of_students, int *number_of_assignments, const string input_filename);
void Format_Case_Of_Names(string names[MAX_CLASS_SIZE][2], const int number_of_students);
void Compute_Total_And_Percent(int scores[MAX_CLASS_SIZE][MAX_NUMBER_OF_ASSIGNMENTS], int total[], float percent[], int number_of_students, int number_of_assignments);
void Write_Formatted_Grades(string names[MAX_CLASS_SIZE][2], int total[], float percent[], const int number_of_students, const string output_filename);
// There is no need to change main. However you are encouraged to write code
// to write data to the console to check the correctness of each of your functions as
// as you work.
int main() {
string input_filename="unformatted_grades.txt";
string output_filename="formatted_grades.txt";
string names[MAX_CLASS_SIZE][2];
int scores[MAX_CLASS_SIZE][MAX_NUMBER_OF_ASSIGNMENTS];
int number_of_students=0;
int number_of_assignments=0;
int total[MAX_CLASS_SIZE];
float percent[MAX_CLASS_SIZE];
Read_Grade_File(names, scores, &number_of_students, &number_of_assignments, input_filename);
Format_Case_Of_Names( names, number_of_students);
Compute_Total_And_Percent( scores, total, percent, number_of_students, number_of_assignments);
Write_Formatted_Grades(names, total, percent, number_of_students, output_filename);
return 0;
}
// Add your code below to define these functions
// remember to add comments to each function to describe the
// 1) purpose, 2) input, and 3) output of the functions
void Read_Grade_File(string names[MAX_CLASS_SIZE][2], int scores[MAX_CLASS_SIZE][MAX_NUMBER_OF_ASSIGNMENTS], int *number_of_students, int *number_of_assignments, const string input_filename){}
void Format_Case_Of_Names(string names[MAX_CLASS_SIZE][2], const int number_of_students){}
void Compute_Total_And_Percent(int scores[MAX_CLASS_SIZE][MAX_NUMBER_OF_ASSIGNMENTS], int total[], float percent[], int number_of_students, int number_of_assignments){}
void Write_Formatted_Grades(string names[MAX_CLASS_SIZE][2], int total[], float percent[], const int number_of_students, const string output_filename){}
INSTRUCTIONS Below!!!!!
Part A: Read_Grade_File(...) 5 points
This function takes the name of the input file and pointers to some data structures that will hold the names and scores for other functions to process as well as pointers to variables that will keep track of the number of students and assignments.
The unformatted grade file has the following structure:
The first line has the keyword number_of_students followed by an integer indicating the number of students.
The second line has the keyword number_of_assignments followed by an integer indicating the total number of assignments for the course
The third line contains three keywords - student_number, first_name, last_name and then integer values to indicate the maximum possible number of points for each assignment. Note all assignments have 10 possible points. There will be one '10' listed for each assignment.
The fourth and all additional lines will have data for one student. First will be a 5 digit student number this is followed by their first then last name. Then scores for each of the assignments are listed.
You may assume that any file we use to test your work will follow this format correctly; however, the number of students and the number of assignments will vary.
Open the file for reading, and process the file contents. Keywords and student numbers can be ignored. Read the number of students and assignments and store those values in the appropriate variables. Then process each of the students. Store the student names in the names array and their scores in the scores array. For example, after reading the sample file the variable names[0][0] should contain the string "BOB" and names[1][1] should contain the string "kerman". scores[0][0] will contain the integer 8 and scores[1][2] will contain the integer 10. Remember to close the file when finished.
Part B: Format_Case_Of_Names(...) 4 points
You may have noticed that some of the student names are lower case, some are uppercase and some are capitalized. This is unacceptable. This function takes the array of first and last names and changes the strings so that the first letter of each string is a capital letter and all other letters are lower case.
Part C: Compute_Total_And_Percent(...) 4 points
This function takes the score array and computes the total score (the sum of all points earned) as well as the final percent as a double and stores these computed results in the appropriate arrays. Remember all assignments are worth 10 points each. Percents should be computed as doubles between 0 and 100.
Part D: Write_Formatted_Grades(...) 5 points
Now that we've done all of the hard work it's time to write the results to a file. However, it's important that these results look really good. Please see the sample output file formatted_grades.txt for an example. Each line should begin with the student's last name followed by a comma and then their first name. After that write their total score and percent to the file. Scores should be aligned so that the ones digit of every total falls in the 22 column. Percents should be values between 0 and 100 written to one decimal place of precision. The decimal point goes in the 28th column. See the example output. I recommend using IO manipulators such as setw and setprecision. Your output file should look exactly like the sample file. You can use diff (linux) or FC (windows) to compare two files from the command line. In the box below character columns are numbered to show text alignment. Remember to close the file when you are finished.
123456789012345678901234567890 Barker, Bob 22 73.3
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