Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CAN SSOMEONE HELP ME WITH THIS C++ ASSIGNMENT! I don\'t have the asmdata.txt fil

ID: 3906154 • Letter: C

Question

CAN SSOMEONE HELP ME WITH THIS C++ ASSIGNMENT! I don't have the asmdata.txt file.

Problem Statement: instructors of C++ would like to have a simple database for printing student performance reports for the class. The software needs to store students details such as Name, ID, Results, and Grade, have search and sort functions, and the ability to load data from a text file and to print reports to both the screen and to a text file The As a student learning the C++ language, you have been tasked to participate in the first phase of the is to develop a software which caters to the initial requirements provided by the project leader program development to create the alpha version of the software. Your initial task Below is the requirement from the project leader for the alpha version of the software The Menu must have the following options: I. Display all Records to Screen 2. import from AsmData.txt File 3. Insert new 4. Search Record by ID & Save to File 5. Search Record with Lowest Girade &Display; to 6. Sort all Records by Name 7. Sort all Records by ID Record Screen Note I: The user must also be given the option to exit the program Note 2: Option 2 must be implemented with the function provided Note 3: Programs without a working Option 2 will not be heavily penalized. The database must store the following data items: Student Name, Student ID, Results (number score), Grade (alphabet grade) Note 4: For Option 3, the user will only key in the Name, Student ID, and Results (score), The program must automatically generate and store the Grade (alphabet grade) based on the Results (number score). Likewise, the AsmData.txt file will only contain these 3 pieces of information, and the Results (number score) must be automaticall generated. The Text file contains data in the following format: Student Name: (up to 32 characters) (up to 15 characters) student ID Results (score) (3 digits integer) The Display and Export to Text file functions for Options 4 should output data in the following format; Student Name: Student ID: John Doe SxxM1234567890 85 Results:

Explanation / Answer

If you have any doubts, please give me comment...

#include<iostream>

#include<iomanip>

#include<string>

#include<fstream>

using namespace std;

#define MAX_RECORDS 100

struct Student{

string name;

string id;

int score;

char grade;

};

void display(Student *, int n);

void import(Student *, int &);

void insert(Student *, int &);

void searchByID(Student *, int);

void searchByLowestGrade(Student *, int );

void sortByID(Student *, int);

void sortByName(Student *, int);

char calcGrade(int);

int main(){

Student *stu = new Student[MAX_RECORDS];

int choice, n=0;

do{

cout<<"**** MENU ****"<<endl;

cout<<"1. Display all Records to Screen"<<endl;

cout<<"2. Import from AsmData.txt File"<<endl;

cout<<"3. Insert new Record"<<endl;

cout<<"4. Search Record by ID & Save to File"<<endl;

cout<<"5. Search Record with Lowest Grade & Display to Screen"<<endl;

cout<<"6. Sort all Records by Name"<<endl;

cout<<"7. Sort all Records by ID"<<endl;

cout<<"8. Exit"<<endl;

cout<<"Enter your choice: "<<endl;

cin>>choice;

switch(choice){

case 1:

display(stu, n);

break;

case 2:

import(stu, n);

break;

case 3:

insert(stu, n);

break;

case 4:

searchByID(stu, n);

break;

case 5:

searchByLowestGrade(stu, n);

break;

case 6:

sortByName(stu, n);

break;

case 7:

sortByID(stu, n);

break;

case 8:

cout<<"Good Bye!"<<endl;

break;

default:

cout<<"Invalid Choice!"<<endl;

}

}while(choice!=8);

return 0;

}

void display(Student *s, int n){

for(int i=0; i<n; i++){

cout<<left<<setw(20)<<"Student Name:"<<s[i].name<<endl;

cout<<left<<setw(20)<<"Student ID:"<<s[i].id<<endl;

cout<<left<<setw(20)<<"Result:"<<s[i].score<<endl;

cout<<left<<setw(20)<<"Grade:"<<s[i].grade<<endl<<endl;

}

}

void import(Student *s, int &n){

ifstream in("AsmData.txt");

if(in.fail()){

cout<<"Unable to open file"<<endl;

return;

}

string fname, lname;

int i=0;

while(!in.eof()){

in>>fname>>lname>>s[i].id>>s[i].score;

s[i].name = fname+" "+lname;

s[i].grade = calcGrade(s[i].score);

i++;

}

in.close();

cout<<"Successfully "<<i<<" records imported."<<endl;

}

char calcGrade(int score){

if(score>=90)

return 'A';

else if(score>=75)

return 'B';

else if(score >= 65)

return 'C';

else if(score>=50)

return 'D';

else

return 'F';

}

void insert(Student *s, int &n){

cout<<"Enter Student Name: ";

cin.ignore();

getline(cin, s[n].name);

cout<<"Enter Student ID: ";

cin>>s[n].id;

cout<<"Enter Score: ";

cin>>s[n].score;

s[n].grade = calcGrade(s[n].score);

n++;

cout<<"Success 1 student added!"<<endl;

}

void searchByID(Student *s, int n){

string id, filename;

cout<<"Enter Student ID to search: ";

cin>>id;

cout<<"Enter filename to store results";

cin>>filename;

ofstream out(filename.c_str());

if(out.fail()){

cout<<"Unable to open file"<<endl;

return;

}

for(int i=0; i<n; i++){

if(s[i].id==id){

out<<left<<setw(20)<<"Student Name:"<<s[i].name<<endl;

out<<left<<setw(20)<<"Student ID:"<<s[i].id<<endl;

out<<left<<setw(20)<<"Result:"<<s[i].score<<endl;

out<<left<<setw(20)<<"Grade:"<<s[i].grade<<endl<<endl;

}

}

out.close();

cout<<"Resutls success saved into "<<filename<<endl;

}

void searchByLowestGrade(Student *s, int n){

char lowest_grade = 'A';

for(int i=0; i<n; i++){

if(s[i].grade<lowest_grade){

lowest_grade = s[i].grade;

}

}

for(int i=0; i<n; i++){

if(s[i].grade==lowest_grade){

cout<<left<<setw(20)<<"Student Name:"<<s[i].name<<endl;

cout<<left<<setw(20)<<"Student ID:"<<s[i].id<<endl;

cout<<left<<setw(20)<<"Result:"<<s[i].score<<endl;

cout<<left<<setw(20)<<"Grade:"<<s[i].grade<<endl<<endl;

}

}

}

void sortByID(Student *s, int n){

for(int i=0; i<n; i++){

for(int j=i+1; j<n; j++){

if(s[i].id<s[j].id){

Student t = s[i];

s[i] = s[j];

s[j] = t;

}

}

}

cout<<"Sort by ID successfully completed"<<endl;

}

void sortByName(Student *s, int n){

for(int i=0; i<n; i++){

for(int j=i+1; j<n; j++){

if(s[i].name<s[j].name){

Student t = s[i];

s[i] = s[j];

s[j] = t;

}

}

}

cout<<"Sort by Name successfully completed"<<endl;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote