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

C++ only 1) Add Records This feature allows you to add general information recor

ID: 3681167 • Letter: C

Question

C++ only

1) Add Records

This feature allows you to add general information records. The student class with data members like student ID (required field), student name (required field), student age (required field), phone number, address, gender (required field), GPA (required field), hobbies (required field), and email address, is required to be declared and used in the system. All the added records in this student information management system are stored in a file.

2) Sort Records and list them in ascending or descending order

It sorts all the records in the system in terms of the feature specified by a user such as GPA, ID, or name in ascending or descending order. The system should be able to differentiate features specified by the user, sort all the records based on the specified feature, and then cout the results. For example, if the user chooses GPA (or other required fields), the results should be ordered by GPA (or other required fields). There are some improvements you can make to this feature to make the list look more attractive.

3) Modify Records

This feature allows you to modify the added records based on user’s input. The modified records are then stored in file.

4) Calculate Salary

A full-time employee is usually fixed for a year. In addition, a full-time employee may receive a bonus. The salary of a part-time employee is usually calculated according to the pay rate per hour and the number of hours worked.

5) Delete Records

This feature is for deleting the added students’ information from the file.

Requirement:

1) You may not use any other external libraries (e.g. for graphical interfaces). Generally a good rule of thumb is that if something was not covered in this course, you should probably not use it (if in doubt, email me!). Stick to a text interface. That is, you need to design a text menu that includes various operating functions. After the application is running, the first display is showing in the menu. Then select the desired operation performed by the user via the menu item project. Please refer to the following figure.

2) Employees’ Information can be defined as classes s (preferably using advanced class features such as inheritance wisely), use the file to save the data. More precisely, classes that are needed to be defined in this project are personType, courseType, employeeType,partTimeEmployee, fullTimeEmployee, studentType, and instructor Type, as show in the figure below. Note that an instructor could also be a student taking courses; you should also consider this case in this project.

3) To help you have a better understanding of the key concepts mentioned in the classes, both simple data type and structured data type are suggested to be used in this project. Besides, pointers, array, user-defined functions, typedef, function overloading, abstract class, class and inheritance, composition, and virtual functions are also strongly recommend to be utilized to facilitate the implementation of this project. Note vectors are not allowed in this project.

4) Read students and instructors’ data from a file and create objects accordingly. When there are any modifications, the file is needed to be updated also.

Explanation / Answer

Vectors have not been used in this program

-------------------------------------------------------------------------------------------------------------------------------

    #include<iostream>
    #include<fstream>
    #include<iomanip>
    
    using namespace std;
    
    
    
    class student
    {
    int idnum;
    char name[50];
    int physics, chemistry, mathematics, english, comscience;
    double per;
    char grade;
    void calculate();   
    public:
    void getdata();   
    void showdata() const;   
    void show_tabular() const;
    int getIDNum() const;
    };
    
    
    void student::calculate()
    {
    per=(physics+chemistry+mathematics+english+comscience)/5.0;
    if(per>=90)
    grade='A+';
    else if(per>=80)
    grade='A';
    else if(per>=75)
    grade='A-';
    else if(per>=70)
    grade='B+';
    else if(per>=65)
    grade='B';
    else if(per>=60)
    grade='B-';
    else if(per>=55)
    grade='C+';
    else if(per>=50)
    grade='C';
    else
    grade='F';
    }
    
    void student::getdata()
    {
    cout<<" Enter The ID number of the student ";
    cin>>idnum;
    cout<<" Enter student's Name: ";
    cin.ignore();
    cin.getline(name,50);
    cout<<" Enter student's physics grade: ";
    cin>>physics;
    cout<<" Enter student's chemistry grade: ";
    cin>>chemistry;
    cout<<" Enter student's mathematics grade: ";
    cin>>mathematics;
    cout<<" Enter student's english grade: ";
    cin>>english;
    cout<<" Enter student's computer science grade: ";
    cin>>comscience;
    calculate();
    }
    
    void student::showdata() const
    {
    cout<<" ID Number: "<<idnum;
    cout<<" Name: "<<name;
    cout<<" Physics: "<<physics;
    cout<<" Chemistry: "<<chemistry;
    cout<<" Mathematics: "<<mathematics;
    cout<<" English: "<<english;
    cout<<" Computer Science: "<<comscience;
    cout<<" Percentage: "<<per;
    cout<<" Letter Grade: "<<grade;
    }
    
    void student::show_tabular() const
    {
    cout<<idnum<<setw(6)<<" "<<name<<setw(10)<<physics<<setw(4)<<chemistry<<setw(4)<<mathematics<<setw(4)
    <<english<<setw(4)<<comscience<<setw(8)<<per<<setw(6)<<grade<<endl;
    }
    
    int student::getIDNum() const
    {
    return idnum;
    }
    
    
    
    void SaveStudent();   
    void displayAll();   
    void Searchdisplay(int);   
    void modifyStudent(int);   
    void deleteStudent(int);   
    void DisplayClassResult();   
    void DisplayResult();   
    
    
    
    
    void write_student()
    {
    student st;
    ofstream outFile;
    outFile.open("student.dat",ios::binary|ios::app);
    st.getdata();
    outFile.write(reinterpret_cast<char *> (&st), sizeof(student));
    outFile.close();
    cout<<" Student record Has Been Created ";
    cin.ignore();
    cin.get();
    }
    
    
    
    void display_all()
    {
    student st;
    ifstream inFile;
    inFile.open("student.dat",ios::binary);
    if(!inFile)
    {
    cout<<"File could not be open !! Press any Key...";
    cin.ignore();
    cin.get();
    return;
    }
    cout<<" DISPLAY ALL RECORD !!! ";
    while(inFile.read(reinterpret_cast<char *> (&st), sizeof(student)))
    {
    st.showdata();
    cout<<" ==================================== ";
    }
    inFile.close();
    cin.ignore();
    cin.get();
    }
    
    
    
    void display_sp(int n)
    {
    student st;
    ifstream inFile;
    inFile.open("student.dat",ios::binary);
    if(!inFile)
    {
    cout<<"File could not be open !! Press any Key...";
    cin.ignore();
    cin.get();
    return;
    }
    bool flag=false;
    while(inFile.read(reinterpret_cast<char *> (&st), sizeof(student)))
    {
    if(st.getIDNum()==n)
    {
    st.showdata();
    flag=true;
    }
    }
    inFile.close();
    if(flag==false)
    cout<<" record not exist";
    cin.ignore();
    cin.get();
    }
    
    
    void modify_student(int n)
    {
    bool found=false;
    student st;
    fstream File;
    File.open("student.dat",ios::binary|ios::in|ios::out);
    if(!File)
    {
    cout<<"File could not be open !! Press any Key...";
    cin.ignore();
    cin.get();
    return;
    }
    while(!File.eof() && found==false)
    {
    
    File.read(reinterpret_cast<char *> (&st), sizeof(student));
    if(st.getIDNum()==n)
    {
    st.showdata();
    cout<<" Please Enter The New Details of student"<<endl;
    st.getdata();
    int pos=(-1)*static_cast<int>(sizeof(st));
    File.seekp(pos,ios::cur);
    File.write(reinterpret_cast<char *> (&st), sizeof(student));
    cout<<" Record Updated";
    found=true;
    }
    }
    File.close();
    if(found==false)
    cout<<" Record Not Found ";
    cin.ignore();
    cin.get();
    }
    
    
    
    void delete_student(int n)
    {
    student st;
    ifstream inFile;
    inFile.open("student.dat",ios::binary);
    if(!inFile)
    {
    cout<<"File could not be open !! Press any Key...";
    cin.ignore();
    cin.get();
    return;
    }
    ofstream outFile;
    outFile.open("Temp.dat",ios::out);
    inFile.seekg(0,ios::beg);
    while(inFile.read(reinterpret_cast<char *> (&st), sizeof(student)))
    {
    if(st.getIDNum()!=n)
    {
    outFile.write(reinterpret_cast<char *> (&st), sizeof(student));
    }
    }
    outFile.close();
    inFile.close();
    remove("student.dat");
    rename("Temp.dat","student.dat");
    cout<<" Record Deleted ..";
    cin.ignore();
    cin.get();
    }
    
    
    void class_result()
    {
    student st;
    ifstream inFile;
    inFile.open("student.dat",ios::binary);
    if(!inFile)
    {
    cout<<"File could not be open !! Press any Key...";
    cin.ignore();
    cin.get();
    return;
    }
    cout<<" ALL STUDENTS RESULT ";
    cout<<"========================================================== ";
    cout<<"R.No Name P C M E CS %age Grade"<<endl;
    cout<<"========================================================== ";
    while(inFile.read(reinterpret_cast<char *> (&st), sizeof(student)))
    {
    st.show_tabular();
    }
    cin.ignore();
    cin.get();
    inFile.close();
    }
    
    
    
    
    int main()
    {
    char ch;
    int num;
    do
    {
    cout<<" ";
    cout<<" 1.CREATE STUDENT RECORD";
    cout<<" 2.DISPLAY ALL STUDENTS RECORDS";
    cout<<" 3.SEARCH STUDENT RECORD ";
    cout<<" 4.MODIFY STUDENT RECORD";
    cout<<" 5.DELETE STUDENT RECORD";
    cout<<" 6. DISPLAY CLASS RESULT";
    cout<<" 7. EXIT";
    cout<<" ";
    cout<<" Please Enter Your Choice (1-7): ";
    cin>>ch;
    switch(ch)
    {
    case '1':    write_student(); break;
    case '2':    display_all(); break;
    case '3':    cout<<" Please Enter Student's ID number: "; cin>>num;
    display_sp(num); break;
    case '4':    cout<<" Please Enter Student's ID number: "; cin>>num;
    modify_student(num);break;
    case '5':    cout<<" Please Enter Student's ID number: "; cin>>num;
    delete_student(num);break;
    case '6' :    class_result(); break;
    case '7':    exit(0);;
    default:    cout<<"";
    }
    }while(ch!='7');
    
    return 0;
    }

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