Assignment 9, Due Dec 2

Design and implement a program that allows the user to keep track of students in a college course. The program will function as a simple database in which students can be inserted, removed and updated. Additionally, the user can display students in order by name or by average, search for students whose average falls in a given range and drop students who are excessively absent. To store the data you can use parallel arrays as discussed in section 7.6.You will need several arrays, all managed in parallel. (Alternatively you may use an array of structs, but we don't expect you to do it that way since we haven't covered that topic yet.) For example, when you sort the array of last names you need to rearrange the elements of the other arrays at the same time so all the data for a particular student is at the same index. You don't need an array of grades, because each grade is computed from the average (e.g. an average of 92 means a grade of 'A').

The biggest part of this assignment is to come up with a good design, using multiple functions to do the different tasks. It will take you a few days to complete a good design so please don't wait until the "last minute" to start the assignment. For your design, try to think about what kinds of tasks there are. For example, you need to display a menu and get the user's choice in a couple of places, so it makes sense to have a function to do that. At a lower level, many of the tasks require the user to enter a number in a certain range (e.g. a non-negative number for average). That suggests a function whose sole job is to query the user for a number and loop until they enter one that's in the correct range. The more you break your code into small pieces (i.e. functions), the easier it will be to code and debug.

Here is sample code that shows sort, search, insert and display functions for parallel arrays. These aren't the exact functions that will be in your program; they are just examples to show how parallel arrays work.

const int MAXPEOPLE = 10;

void sortByWeight(double weights[], double heights[], int length) {
        for (int i = length-1; i > 0 ; i--) 
                for (int j = 0; j < i ; j++)
                        if (weights[j] > weights[j+1]) {
                                swap(weights[j],        weights[j+1]);
                                swap(heights[j],        heights[j+1]);
                        }
}

void sortByHeight(double weights[], double heights[], int length) {
        for (int i = length-1; i > 0 ; i--) 
                for (int j = 0; j < i ; j++)
                        if (heights[j] > heights[j+1]) {
                                swap(weights[j],        weights[j+1]);
                                swap(heights[j],        heights[j+1]);
                        }
}

void searchByWeight(int targetWeight, double weights[], double heights[], int length) {
        for (int i = 0; i < length; i++) 
                if (weights[i] >= targetWeight)
                        cout << weights[i] << "\t" << heights[i] << endl;
        cout << endl;
}

bool insert(double weight, double height, double weights[], double heights[], int & numPeople) {
        if (numPeople < MAXPEOPLE) {
                weights[numPeople] = weight;
                heights[numPeople] = height;
                numPeople++;
                return true;
        }
        else return false;
}

void displayAll(double weights[], double heights[], int numPeople) {
        cout << endl;
        for (int i = 0; i < numPeople; i++)
                cout << weights[i] << "\t" << heights[i] << endl;
        cout << endl;
}

int main() {
        double weights[MAXPEOPLE];
        double heights[MAXPEOPLE];
        int numPeople =0;
        insert(45.5,66.4,weights,heights,numPeople);
        insert(35.2,77.8,weights,heights,numPeople);
        insert(98.5,26.7,weights,heights,numPeople);
        insert(55.1,72.9,weights,heights,numPeople);
        return 0;
} 

Here is my pseudocode:

Create variables/arrays for course information and student’s information
While output is illegal
Enter section number
Create variables to hold a choice for the first and second menus
Create constants for the first menu choices if user wants to add student or exit
Create constants for the second menu to add/remove a student, sort students by name/average, search student by average, update student, drop student for absences, or exit
Prompt user to enter course information
Display the course info
Display the menu and get the user’s choice
While user does not quit from the menu
While choice is invalid
Enter another value
End loop
If user does not exit from menu
Switch case choice
User chooses to add a student:
Enter student’s information
End switch
End if
End loop
User quits from menu

While user does not quit from the menu
While choice is invalid
Enter another value
End loop
If user does not exit from menu
Switch case choice
User chooses to add a student:
Enter student’s information
User chooses to remove student:
Enter student’s ID and remove student
User chooses to sort students by name:
Display course info
Display student’s information alphabetically
User chooses to sort student by average:
Display course info
Display student’s information from lowest to highest average
User chooses to search student by average:
Enter min and max average scores
Display student’s information
User chooses to update student:
Enter student’s ID and display student’s info
Display menu of whether to change first/last name, update absences/average, or return to the main menu
User chooses to drop student for absences:
Enter max number of absences
Ask yes or no before dropping students
Displays how many absences a student has (if necessary)
User decides whether to drop student
Displays how many students were dropped
End switch
End if
End loop
User exits from program
Print a farewell message

Function to add a student
Enter student ID
Enter first and last name
Enter number of absences
Enter student’s average
Display information
End function

Function to remove a student
For each student
Enter student ID
If student ID does not match
Display error message
Remove student
End function

Function to hold a student’s average
Create constants for grade thresholds
Determine the letter grade
End function

Function to sort students by name
For each student
Swap by last name
End loop
End function

Function to sort students by average
For each student
If low average is less than high average
Swap each student by average
End if
End loop
End function

Function to search students by average
For each student
While average is between min and max
Display student by that average
End Loop
End Loop
End Function

Function to update student
For each student
Enter student ID
If student ID does not match
Display error message
If user wants to change first name
Enter new first name
If user wants to change last name
Enter new last name
If user wants to update number of absences
Enter new number of absences
While output is illegal
Enter number of absences
If user wants to update average
Enter new average
While output is illegal
Enter new average
End loop
End function

Function to drop student for absences
For each student
Enter max number of absences
While user enters yes
Display message
Display student
While user enters yes
Choose whether to drop student
Display how many students were dropped
End loop
End function

Here is my solution:

 #include<iostream>
#include<string>
using namespace std;

const int MAX_STUDENTS = 10;
const string EMPTY_STR = "";

const int ADD_CHOICE1 = 1,
          EXIT_CHOICE1 = 2;

const int ADD_CHOICE2 = 1,
          REMOVE_CHOICE = 2,
          SORTNAME_CHOICE = 3,
          SORTAVERAGE_CHOICE = 4,
          SEARCHAVERAGE_CHOICE = 5,
          UPDATE_CHOICE = 6,
          DROP_CHOICE = 7,
          EXIT_CHOICE2 = 8;

const int FIRSTNAME_CHOICE = 1,
          LASTNAME_CHOICE = 2,
          UPDATEABSENCES_CHOICE = 3,
          UPDATEAVERAGE_CHOICE = 4,
          QUITMENU_CHOICE = 5;

string firstNames[MAX_STUDENTS];
string lastNames[MAX_STUDENTS];
string studentIDs[MAX_STUDENTS];
double averages[MAX_STUDENTS];
int absences[MAX_STUDENTS];

void initializeIDs();
int getFirstFreeArrayPosition();
void addCourseDetails();
void addStudentDetails();
int addStudent(string firstName, string lastName, string studentID, double average, int absence);
int findStudent(string studentID);
int removeStudent(string studentID);
void printStudentDetails(int pos);
int grade(double average);
int sortByName(string lastName[], double average[]);
int sortByAverage(string lastName[], double average[]);
int searchByAverage(int targetAverage, int min, int max, string lastName[], double average[]);
int updateStudent(string studentID, string firstName, string lastName, int absences, int average);
void dropStudent(string studentID, int absences, int maxAbsences, double lastName[], int numStudents);
void changeFirstName(string studentID, string firstName, string lastName, int absences, int average);
void changeLastName(string studentID, string firstName, string lastName, int absences, int average);
void updateAbsences(string studentID, string firstName, string lastName, int absences, int average);
void updateAverage(string studentID, string firstName, string lastName, int absences, int average);
void displayTable(string course_code, int section_number, double average, int numStudents);
void showMenu1();
void showMenu2();
void showMenu3();

int main()
{
    int pos=addStudent(firstNames[MAX_STUDENTS],lastNames[MAX_STUDENTS],studentIDs[MAX_STUDENTS],averages[MAX_STUDENTS],absences[MAX_STUDENTS]);
    string course_code;
    int section_number;
    string studentID;
    string firstName;
    string lastName;
    double average;
    int targetAverage;
    int absence;
    int min;
    int max;
    double numStudents;
    int choice1;
    int choice2;

    addCourseDetails();
    do
    {
        showMenu1();
        cout << "Please enter an integer between 1 and 2 (inclusive) : ";
        cin >> choice1;

        while(choice1 < ADD_CHOICE1 || choice1 > EXIT_CHOICE1)
        {
            cout << "Out of range... try again: ";
            cin >> choice1;
        }
        while(!choice1)
        {
            cout << "Not a number... try again: ";
            cin >> choice1;
        }

        if(choice1 != EXIT_CHOICE1)
        {
            switch(choice1)
            {
                case ADD_CHOICE1:
                    addStudentDetails();
                    break;
            }
        }
    }
    while(choice1 != EXIT_CHOICE1);

    if(pos<MAX_STUDENTS)
    {
        printStudentDetails(pos);
    }

    do
    {
        showMenu2();
        cout << "Please enter an integer between 1 and 2 (inclusive) : ";
        cin >> choice2;

        while(choice2 < ADD_CHOICE2 || choice2 > EXIT_CHOICE2)
        {
            cout << "Out of range... try again: ";
            cin >> choice2;
        }

        while(!choice2)
        {
            cout << "Not a number... try again: ";
            cin >> choice2;
        }

        if(choice2 != EXIT_CHOICE2)
        {
            switch(choice2)
            {
                case ADD_CHOICE2:
                    addStudentDetails();
                    int addStudent(firstName, lastName, studentID, average, absence);
                    initializeIDs();
                    break;
                case REMOVE_CHOICE:
                    removeStudent(studentID);
                    break;
                case SORTNAME_CHOICE:
                    sortByName(lastName[MAX_STUDENTS], average[]);
                    displayTable(average, course_code, section_number, numStudents);
                    break;
                case SORTAVERAGE_CHOICE:
                    sortByAverage(lastName[], average[]);
                    displayTable(average, course_code, section_number, numStudents);
                    break;
                case SEARCHAVERAGE_CHOICE:
                    searchByAverage(targetAverage, min, max, lastName[], average[]);
                    displayTable(average, course_code, section_number, numStudents);
                    break;
                case UPDATE_CHOICE:
                    updateStudent(studentID, firstName, lastName, absence, average);
                    displayTable(average, course_code, section_number, numStudents);
                    break;
                case DROP_CHOICE:
                    break;
            }
        }
    }
    while(choice2 != EXIT_CHOICE2);

    cout << "Bye!" << endl;
    return 0;
}

void initializeIds() 
{
    for(int i=0;i<MAX_STUDENTS;i++) 
    {
        studentIDs[i]=EMPTY_STR;
    }
}

int getFirstFreeArrayPosition() 
{
    for(int i=0;i<MAX_STUDENTS;i++)
    {
        if(studentIDs[i]=="") 
        {
            return i;
        }
    }
    return MAX_STUDENTS;    
}

void addCourseDetails()
{
    string course_code;
    int section_number;
    cout << "What is the course code? (e.g. 'CSCI14') ";
    cin >> course_code;
    cout << "What is the section number? ";
    cin >> section_number;
    while(section_number < 0)
    {
        cout << "Value can't be smaller than 0... try again: ";
        cin >> section_number;
    }
    while(!section_number)
    {
        cout << "Not a number... try again: ";
        cin >> section_number;
    }
    cout << "Course " << course_code << ", Section #" << section_number << " created." << endl;
}

void addStudentDetails()
{
    string studentID;
    string fullName;
    string firstName;
    string lastName;
    int absences;
    int average;
    cout << "Enter student ID: ";
    cin >> studentID;
    if(studentID == studentIDs[MAX_STUDENTS])
    {
        cout << "A student with that ID already exists." << endl;
    }
    cout << "Enter the student's first and last name:";
    cin >> firstName >> lastName;
    fullName = firstName + lastName;
    cout << "Enter the number of absences: ";
    cin >> absences;
    while(absences < 0)
    {
        cout << "Value can't be smaller than 0... try again: ";
        cin >> absences;
    }
    while(!absences)
    {
        cout << "Not a number... try again: ";
        cin >> absences;
    }
    cout << "Enter the student's current average: ";
    cin >> average;
    while(average < 0)
    {
        cout << "Value can't be smaller than 0... try again: ";
        cin >> average;
    }
    while(!average)
    {
        cout << "Not a number... try again: ";
        cin >> average;
    }
    initializeIDs();
    cout << "Student " << studentID << "  (" << fullName << ")  has been added." << endl;
}

int addStudent(string firstName, string lastName, string studentID, double average, int absence) 
{
    int pos=getFirstFreeArrayPosition();
    if(pos<MAX_STUDENTS) 
    {
        firstNames[pos] = firstName;
        lastNames[pos] = lastName;
        studentIDs[pos] = studentID;
        averages[pos] = average;
        absences[pos] = absence;
    }
    return pos;
}

int findStudent(string studentID) 
{
    int pos = MAX_STUDENTS;
    return pos;
}

int removeStudent(string studentID)
{
    int pos = findStudent(studentID);
    cout << "Enter student ID: ";
    cin >> studentID;
    if(pos<MAX_STUDENTS)
    {
        cout << "Student " << studentID << " (" << firstNames[MAX_STUDENTS] << lastNames[MAX_STUDENTS] << ")  has been removed." << endl;
        studentIDs[pos] = EMPTY_STR;
    }
    else
    {
        cout << "Student not found." << endl;
    }
    return pos;
}

int grade(double average)
{
    const int A_GRADE = 90,
              B_GRADE = 80,
              C_GRADE = 70,
              D_GRADE = 60;

    if(average >= A_GRADE)
        cout << "A";
    else if(average >= B_GRADE)
        cout << "B";
    else if(average >= C_GRADE)
        cout << "C";
    else if(average >= D_GRADE)
        cout << "D";
    else if(average >= 0)
        cout << "F";
}

int sortByName(string lastName[], double average[])
{
    for(int i; i > 0; i--)
    {
        for(int j = 0; j < i; j++)
        {
            if(lastName[i] > lastName[j])
            {
                swap(lastName[i], lastName[j]);
                swap(average[i], average[j]);
            }
        }
    }
}

int sortByAverage(string lastName[], double average[])
{
    for(int i; i > 0; i--)
    {
        for(int j = 0; j < i; j++)
        {
            if(average[i] > average[j])
            {
                swap(average[i], average[j]);
                swap(lastName[i], lastName[j]);
            }
        }
    }


    }
int searchByAverage(int targetAverage, int min, int max, string lastName[], double average[])
{
    for(int i; i < MAX_STUDENTS; i++)
    {
        cout << "Enter the minimum average score to look for: ";
        cin >> average[i];
        cout << "Enter the maximum average score to look for: ", average[i];
        cin >> targetAverage;
        if(average[i] >= targetAverage)
        {
            cout << average[i] << "\t" << lastName[i] << endl;
        }
        else
        {
            cout << "No students found in that range." << endl;
        }
        while(average[i] < 0)
        {
            cout << "Value can't be smaller than 0... try again: ";
            cin >> average[i];
        }
        while(!average[i])
        {
            cout << "Not a number... try again: ";
            cin >> average[i];
        }
        while(average[i] < min && average[i] > max)
        {
            cout << "Value can't be smaller than " << targetAverage << "... try again: ";
        }
    }
    cout << endl;
}

int updateStudent(string studentID, string firstName, string lastName, int absences, int average)
{
    int choice3;
    for(int i; i > 0; i++)
    {
        cout << "Enter student ID: ";
        cin >> studentID;
        if(studentID != studentIDs[MAX_STUDENTS])
        {
            cout << "Student not found." << endl;
        }
        cout << displayTable(studentID, firstName, lastName, absences, average) << grade(average) << endl;
        do
        {
            showMenu3();
            cout << "Please enter an integer between 1 and 5 (inclusive) : ";
            cin >> choice3;

            while(choice3 < FIRSTNAME_CHOICE || choice3 > QUITMENU_CHOICE)
            {
                cout << "Out of range... try again: ";
                cin >> choice3;
            }
            while(!choice3)
            {
                cout << "Not a number... try again: ";
                cin >> choice3;
            }

            if(choice3 != QUITMENU_CHOICE)
            {
                switch(choice3)
                {
                case FIRSTNAME_CHOICE:
                    changeFirstName(studentID, firstName, lastName, absences, average);
                    break;
                case LASTNAME_CHOICE:
                    changeLastName(studentID, firstName, lastName, absences, average);
                    break;
                case UPDATEABSENCES_CHOICE:
                    updateAbsences(studentID, firstName, lastName, absences, average);
                    break;
                case UPDATEAVERAGE_CHOICE:
                    updateAverage(studentID, firstName, lastName, absences, average);
                    break;
                }
            }
        }
        while(choice3 != QUITMENU_CHOICE);
        return;
    }
}



    void dropStudent(string studentID, int absences, int maxAbsences, double lastName[], int numStudents)
    {
        char ask;
        char drop;
        for(int i = 0; i > numStudents; i++)
        {
            cout << "Enter a maximum number of absences: ";
            cin >> maxAbsences;
            cout << "Ask before dropping (recommended) (y/n): ";
            cin >> ask;
            if(absences > maxAbsences)
            {
                if(ask == 'y' || ask == 'Y')
                {
                    cout << lastName[i] << " " << studentID << " has " << absences << " absences." << endl;
                    cout << "Drop this student? (y/n): ";
                    cin >> drop;
                    if(drop == 'y' || drop == 'y')
                    {
                        cout << (numStudents > 1 ? " students were " : " student was ") << "dropped." << endl;
                        return;
                    }
                    else
                    {
                        cout << "0 students were dropped" << endl;
                    }
                }
                else
                {
                    cout << (numStudents > 1 ? " students were " : " student was ") << "dropped." << endl;
                    return;
                }
            }
            else
            {
                cout << "0 students were dropped" << endl;
            }
        }
    }

    void changeFirstName(string studentID, string firstName, string lastName, int absences, int average)
    {
        cout << "Enter the new First Name: ";
        cin >> firstName;
        cout << "Updated Student record:" << endl;
        cout << studentID << " " << firstName << "\t" << lastName << "\t" << absences << "\t" << average << "\t" << grade(average) << endl;
    }

    void changeLastName(string studentID, string firstName, string lastName, int absences, int average)
    {
        cout << "Enter the new First Name: ";
        cin >> lastName;
        cout << "Updated Student record:" << endl;
        cout << studentID << " " << firstName << "\t" << lastName << "\t" << absences << "\t" << average << "\t" << grade(average) << endl;
    }

    void updateAbsences(string studentID, string firstName, string lastName, int absences, int average)
    {
        cout << "Enter the number of absences: ";
        cin >> absences;
        while(absences < 0)
        {
            cout << "Value can't be smaller than 0... try again: ";
            cin >> absences;
        }
        while(!absences)
        {
            cout << "Not a number... try again: ";
            cin >> absences;
        }
        cout << "Updated Student record:" << endl;
        cout << studentID << " " << firstName << "\t" << lastName << "\t" << absences << "\t" << average << "\t" << grade(average) << endl;
    }

    void updateAverage(string studentID, string firstName, string lastName, int absences, int average)
    {
        cout << "Enter the new average: ";
        cin >> average;
        while(average < 0)
        {
            cout << "Value can't be smaller than 0... try again: ";
            cin >> average;
        }
        while(!average)
        {
            cout << "Not a number... try again: ";
            cin >> average;
        }
        cout << "Updated Student record:" << endl;
        cout << studentID << " " << firstName << "\t" << lastName << "\t" << absences << "\t" << average << "\t" << grade(average) << endl;
    }

    void printStudentDetails(int pos) 
    {
        cout << firstNames[pos];
        cout << lastNames[pos];
        cout << studentIDs[pos];
        cout << averages[pos];
        cout << absences[pos];
        cout << endl;
    }

    void displayTable(string course_code, int section_number, double average, int numStudents)
    {
        int pos;
        cout << endl;
        for(int i = 0; i < numStudents; i++)
        {
            cout << "\t" << "Course: " << course_code << "\t" << "Section #" << section_number << endl;
            cout << endl;
            cout << endl;
            cout << "\t" << "ID" << "\t" << "FirstName  " << "LastName  " << "Absences " << "Average  " << "Grade" << endl;
            cout << printStudentDetails(pos) << grade(average) << endl;
        }
    }

    void showMenu1()
    {
        cout << "Main Menu...\n"
             << "1: Add Student\n"
             << "2: Exit\n";
    }

    void showMenu2()
    {
        cout << "Main Menu...\n"
             << "1: Add Student\n"
             <<   "2: Remove Student\n"
             << "3: Sort by Name\n"
             << "4: Sort by Average\n"
             << "5: Search by Average\n"
             << "6: Update Student\n"
             << "7: Drop for Absence\n"
             << "8: Exit\n";
    }

    void showMenu3()
    {
        cout << "1: Change First Name\n"
             << "2: Change Last Name\n"
             << "3: Update # of absences\n"
             << "4: Update average\n"
             << "5: Return to Main Menu\n";
    }

}

My question is: How can I be able to get the expected outputs for this major program? Are there a lot of lines that needs to be removed/changed? Let me know if I need to shorten my code because it looks too long.

Here are the expected outputs:

What is the course code? (e.g. "CSCI14') physics 4b

What is the section number? 3

Course PHYSICS4B, Section #3 created.

Main Menu...

1: Add Student

2: Exit

Please enter an integer between 1 and 2 (inclusive) : 1

Enter student ID: W12345678

Enter the student's first and last name: Isaac Newton

Enter the number of absences: 4

Enter the student's current average: 68

Student W12345678 (ISAAC NEWTON) has been added.

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 1

Enter student ID: W20452295

Enter the student's first and last name: Bill Gates

Enter the number of absences: 6

Enter the student's current average: 86

Student W20452295 (BILL GATES) has been added.

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 3

        Course: PHYSICS4B       Section #3





        ID          FirstName   LastName    Absences  Average   Grade



        W20452295   BILL        GATES       6         86        B

        W12345678   ISAAC       NEWTON      4         68        D

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 4

    Course: PHYSICS4B       Section #3





    ID          FirstName   LastName    Absences  Average   Grade



    W12345678   ISAAC       NEWTON      4         68        D

    W20452295   BILL        GATES       6         86        B

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 2

Enter student ID: W55555555

Student not found.

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 2

Enter student ID: W12345678

Student W12345678 (ISAAC NEWTON) has been removed.

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 3

    Course: PHYSICS4B       Section #3





    ID          FirstName   LastName    Absences  Average   Grade



    W20452295   BILL        GATES       6         86        B

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 7

Enter a maximum number of absences: 6

Ask before dropping (recommended) (y/n): y

0 students were dropped.

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 7

Enter a maximum number of absences: 5

Ask before dropping (recommended) (y/n): y

BILL GATES W20452295 has 6 absences.

Drop this student? (y/n): n

0 students were dropped.

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 7

Enter a maximum number of absences: 5

Ask before dropping (recommended) (y/n): y

BILL GATES W20452295 has 6 absences.

Drop this student? (y/n): y

1 student was dropped.

Main Menu...

1: Add Student

2: Exit

Please enter an integer between 1 and 2 (inclusive) : 1

Enter student ID: W31415926

Enter the student's first and last name: Albert Einstein

Enter the number of absences: 3

Enter the student's current average: 77

Student W31415926 (ALBERT EINSTEIN) has been added.

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 1

Enter student ID: W3145926

Enter the student's first and last name: Peter Einstein

Enter the number of absences: 2

Enter the student's current average: 64

Student W3145926 (PETER EINSTEIN) has been added.

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 4

    Course: PHYSICS4B       Section #3





    ID          FirstName   LastName    Absences  Average   Grade



    W3145926    PETER       EINSTEIN    2         64        D

    W31415926   ALBERT      EINSTEIN    3         77        C

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 2

Enter student ID: w12341234

Student not found.

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 3

    Course: PHYSICS4B       Section #3





    ID          FirstName   LastName    Absences  Average   Grade



    W31415926   ALBERT      EINSTEIN    3         77        C

    W3145926    PETER       EINSTEIN    2         64        D

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 2

Enter student ID: w3145926

Student W3145926 (PETER EINSTEIN) has been removed.

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 3

    Course: PHYSICS4B       Section #3





    ID          FirstName   LastName    Absences  Average   Grade



    W31415926   ALBERT      EINSTEIN    3         77        C

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 0

Out of range... try again: 9

Out of range... try again: -2

Out of range... try again: 6

Enter student ID: W31415926

    ID          FirstName   LastName    Absences  Average   Grade



    W31415926   ALBERT      EINSTEIN    3         77        C

1: Change First Name

2: Change Last Name

3: Update # of absences

4: Update average

5: Return to Main Menu

Please enter an integer between 1 and 5 (inclusive) : 0

Out of range... try again: 6

Out of range... try again: 1

Enter the new First Name: Al

Updated Student record:

    W31415926   AL          EINSTEIN    3         77        C

1: Change First Name

2: Change Last Name

3: Update # of absences

4: Update average

5: Return to Main Menu

Please enter an integer between 1 and 5 (inclusive) : 3

Enter the number of absences: 5

Updated Student record:

    W31415926   AL          EINSTEIN    5         77        C

1: Change First Name

2: Change Last Name

3: Update # of absences

4: Update average

5: Return to Main Menu

Please enter an integer between 1 and 5 (inclusive) : 4

Enter the new average: 81

Updated Student record:

    W31415926   AL          EINSTEIN    5         81        B

1: Change First Name

2: Change Last Name

3: Update # of absences

4: Update average

5: Return to Main Menu

Please enter an integer between 1 and 5 (inclusive) : 3

Enter the number of absences: -1

Value can't be smaller than 0... try again: 6

Updated Student record:

    W31415926   AL          EINSTEIN    6         81        B

1: Change First Name

2: Change Last Name

3: Update # of absences

4: Update average

5: Return to Main Menu

Please enter an integer between 1 and 5 (inclusive) : 4

Enter the new average: -4

Value can't be smaller than 0... try again: 82

Updated Student record:

    W31415926   AL          EINSTEIN    6         82        B

1: Change First Name

2: Change Last Name

3: Update # of absences

4: Update average

5: Return to Main Menu

Please enter an integer between 1 and 5 (inclusive) : 5

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 1

Enter student ID: W33333333

Enter the student's first and last name: Galileo Galilei

Enter the number of absences: 2

Enter the student's current average: 99

Student W33333333 (GALILEO GALILEI) has been added.

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 3

    Course: PHYSICS4B       Section #3





    ID          FirstName   LastName    Absences  Average   Grade



    W31415926   AL          EINSTEIN    6         82        B

    W33333333   GALILEO     GALILEI     2         99        A

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 4

    Course: PHYSICS4B       Section #3





    ID          FirstName   LastName    Absences  Average   Grade



    W31415926   AL          EINSTEIN    6         82        B

    W33333333   GALILEO     GALILEI     2         99        A

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 5

Enter the minimum average score to look for: 45

Enter the maximum average score to look for: 81

No students found in that range.

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 5

Enter the minimum average score to look for: 45

Enter the maximum average score to look for: 82

    ID          FirstName   LastName    Absences  Average   Grade



    W31415926   AL          EINSTEIN    6         82        B

Main Menu...

1: Add Student

2: Remove Student

3: Sort by Name

4: Sort by Average

5: Search by Average

6: Update Student

7: Drop for Absence

8: Exit

Please enter an integer between 1 and 8 (inclusive) : 8

Bye

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.