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

Hello, I have some of the program working however am having difficulties getting

ID: 3564546 • Letter: H

Question

Hello,

I have some of the program working however am having difficulties getting the lists to display correctly. I'd like to see a working program so that I can see where I went wrong and apply it to my own program.

Problem Question:

Write a program that stores lists of names (the last name first) and ages in parallel arrays and sorts the names into alphabetical order keeping the ages with the correct names. The original arrays of names and ages should remain no changes. Therefore, you need to create an array of character pointers to store the addresses of the names in the name array initially. Apply the selection sort to this array of pointers so that the corresponding names are in alphabetical order. Use the pointer to arrays example from CIS 236 as reference. You should use another array of pointers to age array to make sure the age is corresponding to the correct name. Please see the additional program requirements at the bottom of this page.

Hint: Create a class named Student which contains name array and age array.

Problem Requirement:

a)      You must create three separate files: Student.h, Student.cpp, and Lab5.cpp files.

b)      Your program should run correctly with the same inputs and outputs as given in the sample run.         

Problem Output:

Enter number of people <0 . . 50>

>6

Enter name 1 (last name, first name): Ryan, Elizabeth

Enter age 1: 62

Enter name 2 (last name, first name): Mcintyre, Osborne

Enter age 2: 84

Enter name 3 (last name, first name): DuMond, Kristin

Enter age 3: 18

Enter name 4(last name, first name): Larson, Lois

Enter age 4: 42

Enter name 5(last name, first name): Thorpe, Trinity

Enter age 5: 15

Enter name 6(last name, first name): Ruiz, Pedro

Enter age 6: 35

Original List

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

Ryan, Elizabeth                           62

McIntyre, Osborne                      84

DuMond, Kristin                          18

Larson, Lois                                42

Thorpe, Trinity                             15

Ruiz, Pedro                                 35

Alphabetized List

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

DuMond, Kristin                         18

Larson, Lois                                42

MicIntyre, Osborn                        84

Ruiz, Pedro                                35

Ryan, Elizabeth                          62

Thorpe, Trinity                            15

Original List

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

Ryan, Elizabeth                           62

McIntyre, Osborne                      84

DuMond, Kristin                          18

Larson, Lois                                42

Thorpe, Trinity                             15

Ruiz, Pedro                                 35

Any assistance is greatly appreciated.

Explanation / Answer

//Lab 5.cpp #include #include #include #include "Student.h" using namespace std; int main() { Student stu; stu.getStudent(); stu.displayStudent(); stu.sortStudent(string *nameArray[], int *ageArray[]); system("pause"); }; //Student.h #include #include #include using namespace std; class Student { public: Student(); void setStudent(); int getStudent(); int sortStudent(string *nameArray[], int *ageArray[]); void displayStudent(); void displaySorted(string *nameArray[], int *ageArray); private: string names[50]; int age[50]; int size; }; //Student.cpp using namespace std; #include #include #include "Student.h" Student::Student() { setStudent(); }; void Student::setStudent() { for(int i = 0; i
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