Help with this C++ program please, I\'m struggling with this. In this project, y
ID: 3822561 • Letter: H
Question
Help with this C++ program please, I'm struggling with this.
In this project, you are asked to design, develop, implement, and test a prototype (a model for an exam software system. This exam is administered to students graduating with a degree in Social Science who would like to enter the Graduate Program. The students' must pass this exam to be admitted into the Graduate Program. The basic requirements for such a system include the following: l. Student Registration: Students taking the exam are entered into the grading system via an input file. The file contains the students' names, ID numbers, and answers to a multiple choice exam. 2. Grading: The user enters an "Answer Key" and then the system grades the students' answers and calculates the students' total points, average, and letter grade earned lyou are not required to perform data validation 3. Grade Reporting: The system generates a report (in ascending order) of each student's name, ID number, exam answers, total points, average and letter grade earned; 4. Analysis Reporting: The system produces three reports (in ascending order) that include the names and graded results of the students who made an A, B, or C (full admission into the program), the names and graded results of the students who made a D (conditional admission into the program), and the names and graded results of the students who failed not admitted to the program), Detailed Specification: i. Student Registration: The system will read the students' ID number (an integer, full name (name will be the format: last name, first name), and the students' 10 multiple choice answers from an input file provided. Allow the program to read the information from the file for up to 50 students. This information will be displayed in the Grading Report as illustrated in the Sample Inputouput section. 2. Grading: The exam consists of 10 multiple-choice questions. The answer key is entered by the user. Valid choices for each of the exam questions are A, B, C, or D The grading rules are specified as follows: Each comect answer counts 5 points in raw score. The percentile score is the quotient between the total raw score received and the maximum possible. The percentile Grading Report as illustrated in the Sample Inputouput section 3. Grading Reporting The Grade Report will be sorted in ascending order by name, displaying all the students' information. (See the sample Grading Report in the Sample Inpuwoutput section.) 4. Analysis Reporting Three separate reports will be produced, sorted in ascending order by name, and grouped in the following categories Admitted into the Graduate Program (students who earned an A, B, or CO, b) Conditional Admission (students who earned a D); c) Admission Denied (students who earned an FO (See the sample Grading Report in the Sample Inpuvoutput section.) Solution Design: Function decomposition: accomplish each specified task with well designed modular functions. (You will receive a zero for your grade ifyou do not use functions) Solution integration: integrate the modules into a prototype (a working model, you will receive a zero for your grade if the code does not run) for an exam software system. All coding standards should be followed. You are not required to perform data validation or have the program repeatable.Explanation / Answer
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <cstring>
using namespace std;
void readDataFromFile();
void calculateResult();
void displayResult();
void removeCharsFromString( string &str);
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<total_record; i++) {
check = record[i];
for(j=i; j>=1 && (check.full_name < record[j-1].full_name); j--) {
record[j] = record[j-1];
record[j-1] = check;
}
}
}
int main()
{
readDataFromFile();
cout << endl << "-------------------------------";
cout << endl << "Enter Answer Keys : " ;
for(int i=0; i<10; i++) {
cout << endl << "Answer " << i+1 << " : ? " ;
cin >> answer_keys[i];
}
calculateResult();
displayResult();
return 0;
}
void readDataFromFile() {
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 << endl << "-------------------------------------------------------------------------------------";
cout << endl << "Grade Report" << endl ;
cout << endl << "Student ID Student Name Answers Total Pts Average Letter Grade ";
cout << endl << "-------------------------------------------------------------------------------------";
for (int i=0; i < total_record; i++) {
removeCharsFromString(record[i].answers);
int points = 0;
for(int j=0; j<10; j++) {
if(record[i].answers[j] == answer_keys[j]) {
points += 5;
}
}
record[i].total_points = points;
record[i].avg = (points * 100 / 50);
if(record[i].avg >= 90) {
record[i].letter_grade = 'A';
} else if(record[i].avg >= 80 && record[i].avg <= 89) {
record[i].letter_grade = 'B';
} else if(record[i].avg >= 70 && record[i].avg <= 79) {
record[i].letter_grade = 'C';
} else if(record[i].avg >= 60 && record[i].avg <= 69) {
record[i].letter_grade = 'D';
} else {
record[i].letter_grade = 'F';
}
cout << endl << setw(4) << record[i].stud_id << setw(22) << record[i].full_name << setw(12) << record[i].answers << setw(8) << record[i].total_points << setw(8) << record[i].avg << setw(8) << record[i].letter_grade;
}
}
void displayResult() {
cout << endl << "--------------------------------------------------------------------";
cout << endl << "Student Admitted to the Graduate Program" << endl ;
cout << endl << "Student ID Student Name Total Pts Average Letter Grade ";
cout << endl << "--------------------------------------------------------------------";
for (int i=0; i < total_record; i++) {
if(record[i].letter_grade == 'A' || record[i].letter_grade == 'B' || record[i].letter_grade == 'C')
cout << endl << setw(4) << record[i].stud_id << setw(22) << record[i].full_name << setw(8) << record[i].total_points << setw(8) << record[i].avg << setw(8) << record[i].letter_grade;
}
cout << endl << "--------------------------------------------------------------------";
cout << endl << "Student with Conditional Admission to the Graduate Program" << endl ;
cout << endl << "Student ID Student Name Total Pts Average Letter Grade ";
cout << endl << "--------------------------------------------------------------------";
for (int i=0; i < total_record; i++) {
if(record[i].letter_grade == 'D')
cout << endl << setw(4) << record[i].stud_id << setw(22) << record[i].full_name << setw(8) << record[i].total_points << setw(8) << record[i].avg << setw(8) << record[i].letter_grade;
}
cout << endl << "--------------------------------------------------------------------";
cout << endl << "Student not Allowed Admission" << endl ;
cout << endl << "Student ID Student Name Total Pts Average Letter Grade ";
cout << endl << "--------------------------------------------------------------------";
for (int i=0; i < total_record; i++) {
if(record[i].letter_grade == 'F')
cout << endl << setw(4) << record[i].stud_id << setw(22) << record[i].full_name << setw(8) << record[i].total_points << setw(8) << record[i].avg << setw(8) << record[i].letter_grade;
}
}
void removeCharsFromString( string &str) {
str.erase( remove(str.begin(), str.end(), ' '), str.end() );
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.