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

You are required to design a program studentRecord.cpp that will be used to keep

ID: 3629862 • Letter: Y

Question

 You are required to design a program studentRecord.cpp that will be used to keep track of students’ studies in uni undergraduate courses. This program will be menu driven, and the user should be able to interactively enter and process on students’ records. More specifically, the program should perform student record searching; list students enrolled in a course, students eligible to graduate and all students of various uni courses; and update/add/delete a student’s record. As the outputs of above processes, the students’ records should be displayed with all the details including ID, Name, Course Code and Credit Points. Same as usual practice adopted by many real systems, each student’s ID should be unique and be used to determine a record in the developed program.

The following list of specific requirements is roughly in the order of complexity, with the later items being more challenging in general. It is anticipated that one has to have a solid work for items 1-4 of Part I in order to achieve a pass grade for this assignment. Part II is what a student should be able to do well if he or she aims to achieve a credit or above, while Part III is for those who aim at a distinction or higher grade for this assignment.

For simplicity, we always assume that the program will be run under Microsoft Windows.

PART-I:

Basic Program Requirements

1. The program studentRecord.cpp should be menu-driven, and be able to display the menu looked like

MAIN MENU

0. Exit

1. Search for a student

2. List students enrolled in a course

3. List students eligible to graduate

4. List all students

5. Update a student record

6. Add a student record

7. Delete a student record

Your choice ->

You may use system calls such as system(“cls”), system(“pause”); and system(“echo.”) to help maintain the above user interface.

2. This is for the implementation of the menu options 1 to 4. For simplicity, we assume that the total number of students will not exceed 500 within the program. To accommodate up to 500 student records, consequently, you can declare an array of structures with this size in the main() of studentRecord.cpp. The array should originally contain three records in order to run the program before adding any new records. As a result, you need to declare and initialize the array with the three records as given below:

 

const int MAXRECORD = 500;

struct stdRecord

{

string studentID;

string studentName;

int courseCode;

int creditPoint;

};

stdRecord stdRec[MAXRECORD]={"15000000","Joshua Andrew Smith", 3506, 240,

"16666666", "Jack Williams", 3506, 180,

"17000010", "Lily Jones", 3639, 110};

A counter can be used to record the number of records stored in the array. After initializing the array of structures, for example, the counter should take a value of 3.

Instead of the array of structures, you can also choose to use parallel arrays. You should then declare four arrays with the same size, i.e., string studentID[MAXRECORD], string studentName[MAXRECORD], int courseCode[MAXRECORD] and int creditPoint[MAXRECORD] separately, and initialize them with the above three records.

When menu Option 1 is selected, the program will prompt for a student ID and search for the corresponding student. If the record is found, the details of all the four fields will be displayed in an appropriate format. Otherwise a “Not Found” message should be displayed. The user can then choose to start a new search or return to the main menu. When menu Option 2 is selected, the program will prompt for the course code and then list all students enrolled in the course. To receive a correct input, the program can list all

the available course codes (3506, 3633, 3634 and 3639, see Part II 4.) in the prompt. When menu Option 3 is selected, the program will list students eligible to graduate, i.e., those who have achieved 240 credit points. Option 4 will list with all the students enrolled in different courses. As aforementioned, the outputs of the processes option 1~4 should include details of ID, Name, Course Code and Credit Point of each record. Every time the processing of one option is complete, the program should return to the main menu until the exit option is selected.

If you do not plan to implement options 5, 6 and 7, you should write a stub function for each of them.

3. (1 mark) For the program that has been developed up to this point, i.e., the display of the menu and the implementation of the options 0 to 4, draw the Structure Diagram.

 

PART-II:

Implementation of Option 5, 6 & 7

The purpose of this part is to implement option 5, 6 and 7 included in the menu of Part-I.

4. When Option 5 is selected, the program should prompt for the ID and perform a search, and if the target record is found, update its courseCode and/or creditPoint (user can choose to update neither, either or both). Otherwise a “Not Found” message is displayed and the user can choose to update another record or return to the main menu. It is assumed that uni offers four undergraduate courses with the codes as given in Part I. For the credit point, the value should fall in the range 0 ~ 240, as multiples of 10. The validations to the input course code and credit point should be performed accordingly.

 

5. Option 6 allows the user to add a new record to the array of structures. Since each student’s ID is unique, the function should first search the array to assure that the new ID does not exist in the array, and the record can then be added at the end of the list. Adding a record with an identical ID should be denied. As done in Option 5, the course code and the credit point of the new record should be validated in the same way. Another failure of adding a new record is due to the limitation of the array size, which should be checked at the beginning.

 

6. The delete (Option 7) command removes one record from the array if the target record is found to match the student ID provided by the user. The program should then make all the records after the deleted one shift leftward to fill the hole caused by the deletion. Again, a message should be displayed if the target record is not found. The user may then choose to delete another record or return to the main menu.

 

PART-II: Advanced Features

The purpose of this part is to extend and polish that basic program described in Part I&II. The functionality of this extended C++ program, xStudentRecord.cpp, should contain the following additional features.

7. As you may probably notice that the original three student records are sorted in an ascending order according to the student ID. Should Option 6 can add records in right positions, this ascending order would be maintained since all the other operations have no influence to the order. For example, if the fourth record with a studentID "16666656" is to be added in the original list, the record should be put at the second position, i.e., the adding operation should first shuffle the two records with studentID "16666666" and "17000010" rightward to leave space in the array for the new record. For this new requirement, you need to rewrite the function(s) for Option 6 in xStudentRecord.cpp.

 

It is known that the studentID is a string and can be directly compared using the relational operators. For instance, we have "16666656" < "16666666", "15000000" < "9888888”, and "17000000" < "a000" (not a valid UWS student ID). You should avoid using invalid studentIDs, although this field, together with the studentName, is not required to validate in this assignment.

After rewrite the adding function(s) for Option 6 to maintain the ascending order, you can replace the linear search in studentRecord.cpp by a binary search. If you analyse the binary search carefully, you may find the search can not only check if a target exists in a list, but also find the position to insert the target if it is not in the list yet.

General Requirement

In general, the program should be robust and should never crash. It should issue appropriate messages on whether a request has been successful or what has actually been done as a result. For instance, if the user aborts the process of an option, the program should acknowledge that. When an invalid input has been enter, such as in selecting an option of the menu, or inputting a course code or credit points, the program should display an error message and remind the user to give a new input. The output of the program should be well formatted and frequently clear the screen. In short, the program should be informative of its behaviour and should achieve a sensible user interfacing.

Input and validating input are an important issue of this assignment. You can consider to use getline(cin, string), cin.get(ch) in conjunction with normal input operations. Besides, you may need to use cin.clear( ) and cin.ignore( ) functions to restore the input channel and empty the input buffer, which may be left something from previous processes.

Please be advised that you are free to design your own logic in whichever way you wish, particularly in Part II and Part III, as long as it is consistent with the general design principles and meet the requirements of this assignment.

Some Screenshots

Below is a list of screen shots of running a sample implementation. This is just one illustration, and the interface design of your program may well be completely different.

MAIN MENU

0. Exit

1. Search for a student

2. List students enrolled in a course

3. List students eligible to graduate

4. List all students

5. Update a student record

6. Add a student record

7. Delete a student record

 

Your choice-> 1

Enter the student ID to search-> 15000000

The record with the id is:

StudentID StudentName CourseCoce CreditPoint

15000000 Joshua Andrew Smith 3506 240

Have completed the requested process.

Press any key to continue . . .

 

MAIN MENU

0. Exit

1. Search for a student

2. List students enrolled in a course

3. List students eligible to graduate

4. List all students

5. Update a student record

6. Add a student record

7. Delete a student record

 

Your choice-> 2

Enter the course code {3506, 3633, 3634 or 3639} -> 3506

The student(s) enrolled in the course is(are):

StudentID StudentName CourseCoce CreditPoint

15000000 Joshua Andrew Smith 3506 240

16666666 Jack Williams 3506 150

There is(are) 2 student(s) enrolled in the course.

Have completed the requested process.

Press any key to continue . . .

 

MAIN MENU

0. Exit

1. Search for a student

2. List students enrolled in a course

3. List students eligible to graduate

4. List all students

5. Update a student record

6. Add a student record

7. Delete a student record

 

Your choice-> a

Invalid input!

Your choice-> 9

Invalid input!

Your choice-> 3

The student(s) eligible to graduate is(are):

StudentID StudentName CourseCoce CreditPoint

15000000 Joshua Andrew Smith 3506 240

There is(are) 1 graduate student(s).

Have completed the requested process.

Press any key to continue . . .

 

MAIN MENU

0. Exit

1. Search for a student

2. List students enrolled in a course

3. List students eligible to graduate

4. List all students

5. Update a student record

6. Add a student record

7. Delete a student record

 

Your choice-> 5

Enter the student ID to update -> 12345678

The record with ID 12345678 is not found

Enter y or Y to update another record, others to return to the main menu.

y

Enter the student ID to update -> 16666666

The record is:

StudentID StudentName CourseCoce CreditPoint

16666666 Jack Williams 3506 150

Enter y or Y to update the course code, others to keep the original one.

y

Enter the course code {3506, 3633, 3634 or 3639} -> 3639

Enter y or Y to update the credit point, others to keep the original one.

y

Enter the credit point as a multiple of 10 and in the range [0, 240]-> 123

Enter the credit point as a multiple of 10 and in the range [0, 240]-> 140

Have completed the requested process.

Press any key to continue . . .

 

MAIN MENU

0. Exit

1. Search for a student

2. List students enrolled in a course

3. List students eligible to graduate

4. List all students

5. Update a student record

6. Add a student record

7. Delete a student record

 

Your choice-> 4

All students are listed below:

StudentID StudentName CourseCoce CreditPoint

15000000 Joshua Andrew Smith 3506 240

16666666 Jack Williams 3639 140

17000010 Lily Jones 3639 120

Have completed the requested process.

Press any key to continue . . .

 

MAIN MENU

0. Exit

1. Search for a student

2. List students enrolled in a course

3. List students eligible to graduate

4. List all students

5. Update a student record

6. Add a student record

7. Delete a student record

 

Your choice-> 0

 

Bye for now!

Press any key to continue . . .

Explanation / Answer

Dear,
 Here is the C++ programming code... #include<iostream>
#include<string>

using namespace std;

struct stdRecord
{
string studentID;
string studentName;
int courseCode;
int creditPoint;
};

const int MAXRECORD = 500;

int menu();
void searchStudent(stdRecord[],int);
void showByCourse(stdRecord[],int);
void showEligible(stdRecord[],int);
void showAll(stdRecord[],int);
void update(stdRecord[],int );
void add(stdRecord[],int *);
void deleteRecord(stdRecord[],int *);
void findCourses(stdRecord [],int );
int main()
{
    stdRecord stdRec[MAXRECORD]={"15000000","Joshua Andrew Smith", 3506, 240,"16666666", "Jack Williams", 3506, 180,"17000010", "Lily Jones", 3639, 110};
    int counter=3;
    int choice;
    do
    {
        choice=menu();
        switch(choice)
        {
        case 0: cout<<"Bye for Now"<<endl;
            break;
        case 1: searchStudent(stdRec,counter);
            break;
        case 2:showByCourse(stdRec,counter);
            break;
        case 3:showEligible(stdRec,counter);
            break;
        case 4:showAll(stdRec,counter);
            break;
        case 5:update(stdRec,counter);
            break;
        case 6:add(stdRec,&counter);
            break;
        case 7:deleteRecord(stdRec,&counter);
            break;
        }
    }while(choice!=0);
    system("pause");
}

int menu()
{
    int choice;
    cout<<"0. Exit"<<endl
        <<"1. Search for a student"<<endl
        <<"2. List students enrolled in a course"<<endl
        <<"3. List students eligible to graduate"<<endl
        <<"4. List all students"<<endl
        <<"5. Update a student record"<<endl
        <<"6. Add a student record"<<endl
        <<"7. Delete a student record"<<endl
        <<"Your choice ->";
    cin>>choice;
    return choice;
}

void searchStudent(stdRecord stdRec[],int counter)
{
    string ID;
    cout<<"Enter the student ID to search-> ";
    getline(cin,ID);

    for(int i=0;i<counter;i++)
    {
        if(stdRec[i].studentID.compare(ID)==0)
        {
            cout<<"The record with the id is:"<<endl;
            cout<<"StudentID StudentName CourseCoce CreditPoint"<<endl;
            cout<<stdRec[i].studentID<<" "<<stdRec[i].studentName<<" "<<stdRec[i].courseCode<<" "<<stdRec[i].creditPoint<<endl;
            cout<<"Have completed the requested process."<<endl;
            system("pause");
            system("cls");
            return;
        }
    }
    char ch;
    cout<<"Not Found"<<endl;
    cout<<"Do you want search another record(Y/N)";
    cin>>ch;
    ch=tolower(ch);
    if(ch=='y')
        searchStudent(stdRec,counter);
    else
    {
        cout<<"Have completed the requested process."<<endl;
        system("pause");
        system("cls");
    }
}
void findCourses(stdRecord stdRec[],int counter)
{
        int courses[500];
    int coursecount=0;
    cout<<" Enter the course code {";
    bool found;
    for(int i=0;i<counter;i++)
    {
        found=false;
        for(int j=0;j<coursecount;j++)
        {
            if(stdRec[i].courseCode==courses[j])
            {
                found=true;
                break;
            }
        }
        if(!found)
            courses[coursecount++]=stdRec[i].courseCode;
    }
    cout<<" Enter the course code {";
    for(int j=0;j<coursecount-1;j++)
        cout<<courses[j]<<", ";
    cout<<"or "<<courses[coursecount-1]<<"->";
}

void showByCourse(stdRecord stdRec[],int counter)
{
    int courseCode;
    findCourses(stdRec,counter);
    cin>>courseCode;
    cout<<"The student(s) enrolled in the course is(are):"<<endl;
    cout<<"StudentID StudentName CourseCoce CreditPoint"<<endl;
    int studentsCount=0;
    for(int i=0;i<counter;i++)
    {
        if(stdRec[i].courseCode==courseCode)   
        {
            cout<<stdRec[i].studentID<<" "<<stdRec[i].studentName<<" "<<stdRec[i].courseCode<<" "<<stdRec[i].creditPoint<<endl;
            studentsCount++;
        }
    }
    cout<<"There is(are) "<<studentsCount<<" student(s) enrolled in the course."<<endl;
    cout<<"Have completed the requested process."<<endl;
    system("pause");
    system("cls");
}

void showEligible(stdRecord stdRec[],int counter)
{
    cout<<"The student(s) eligible to graduate is(are):"<<endl;
    int studentsCount=0;
    for(int i=0;i<counter;i++)
    {
        if(stdRec[i].creditPoint>=240)   
        {
            cout<<stdRec[i].studentID<<" "<<stdRec[i].studentName<<" "<<stdRec[i].courseCode<<" "<<stdRec[i].creditPoint<<endl;
            studentsCount++;
        }
    }
    cout<<"There is(are) "<<studentsCount<<" graduate student(s)."<<endl;
    cout<<"Have completed the requested process."<<endl;
    system("pause");
    system("cls");
}
void showAll(stdRecord stdRec[],int counter)
{
    cout<<"All students are listed below:"<<endl;
    for(int i=0;i<counter;i++)
    {
            cout<<stdRec[i].studentID<<" "<<stdRec[i].studentName<<" "<<stdRec[i].courseCode<<" "<<stdRec[i].creditPoint<<endl;
    }
    cout<<"Have completed the requested process."<<endl;
    system("pause");
    system("cls");
}

void update(stdRecord stdRec[],int counter)
{
    char keepGoing;
    string ID;
    do
    {
   
    cout<<"Enter the student ID to update-> ";
    getline(cin,ID);
    bool flag=false;
    char choice;
    for(int i=0;i<counter;i++)
    {
        if(stdRec[i].studentID.compare(ID)==0)
        {
            cout<<"The record with the id is:"<<endl;
            cout<<"StudentID StudentName CourseCoce CreditPoint"<<endl;
            cout<<stdRec[i].studentID<<" "<<stdRec[i].studentName<<" "<<stdRec[i].courseCode<<" "<<stdRec[i].creditPoint<<endl;
            cout<<"Enter y or Y to update the course code, others to keep the original one."<<endl;
            cin>>choice;
            if(choice=='y'||choice=='Y')
            {
                    int courseCode;
                    findCourses(stdRec,counter);
                    cin>>courseCode;
                    stdRec[i].courseCode=courseCode;
            }
            cout<<"Enter y or Y to update the credit, others to keep the original one."<<endl;
            cin>>choice;
            if(choice=='y'||choice=='Y')
            {
                int credits;
                cout<<"Enter Credit points";
                cin>>credits;
                stdRec[i].creditPoint=credits;
            }
            flag=true;
            break;
        }
    }
    if(!flag)
    {
    cout<<"The record with the id "<<ID<<" not Found"<<endl;
    }
    cout<<"Do you want update another record(Y/N)";
    cin>>keepGoing;
    keepGoing=tolower(keepGoing);
    }while(keepGoing=='y');
   
    cout<<"Have completed the requested process."<<endl;
    system("pause");
    system("cls");
}
void add(stdRecord stdRec[],int *counter)
{
    string studentID;
    string studentName;
    int courseCode;
    int creditPoint;
    cout<<"Enter Student ID :";
    cin>>studentID;
    bool flag=true;
    for(int i=0;i<*counter;i++)
    {
        if(stdRec[i].studentID.compare(studentID)==0)
        {
            flag=false;
            break;
        }
    }
        if(flag)
        {
            stdRec[*counter].studentID=studentID;
            cout<<"Enter Student Name";
            getline(cin,studentName);
            stdRec[*counter].studentName=studentName;
            cout<<"Enter Course Code";
            cin>>courseCode;
            stdRec[*counter].courseCode=courseCode;
            cout<<"Enter Credit Points";
            cin>>creditPoint;
            stdRec[*counter] .creditPoint=creditPoint;
        }
        else
        {
            cout<<"Student Id Exists"<<endl;
        }
    cout<<"Have completed the requested process."<<endl;
    system("pause");
    system("cls");
}
void deleteRecord(stdRecord stdRec[],int *counter){}
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