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

Code in C++ and include algorithm Instructions: Part I: Create and print out the

ID: 3916728 • Letter: C

Question

Code in C++ and include algorithm

Instructions:

Part I:

Create and print out the two arrays: (Be sure to do this first) You are allowed to hard code these arrays into your program. The data is as follows:

Anne 30

Bob 150

Ralph 305

Tim 225

Barbara 135

Jane 160

Steve 80

Tom 200

Mike 165

Shirley 90

Pam 100

Frank 120

Part II: The elevators in our building have an 1100 lb. load limit. Determine which people in the list above get on the elevator. Print their names, weights, total weight, and how many got on.

?

Part III: Rearrange these people in descending sequence by weight and print the two arrays. Determine again how many may ride the elevator, printing out their names, weights, total weight and the number of how many people got on.

Part IV: Rearrange these people in ascending sequence by name (USE A DIFFERENT SORT ALGORITHM THAN THE ONE YOU USED IN PART III) and print the two arrays. Determine again how many may ride the elevator, printing out their names, weights, total weight and the number of how many people got on.

Part V: Have the program determine which method allowed the most people to get on the elevator. The program should compare the three different counts of how many people got on the elevator.

This program should include:

• 2 sort methods

• a method to determine how many people get on the elevator (will be called 3 times)

• a print method which prints both arrays (include a size parameter and it can be called 6 times).

Make sure all methods are writen to handle n elements, not just 12. You can pass 12 from main to n in the method/function.

Run:

You only have to run this program once since the data is embedded in the program. Read the data from a file and put the results on an output file. Print the output file using Notepad or some other editor.

Explanation / Answer

#include<iostream>

using namespace std;

int main()

{

            char name[12][15]={“ Anne”, “Bob”, “Ralph”, “Tim”, “Barabara”, “Jane”, “Steve”, “Tom”, “Mike”, “Shirley”, “Pam”, “Frank”};

            char new_name[12][15];

            int weight[12]= {30, 150, 305, 225, 135, 160, 80, 200, 165, 90, 100, 120};

            int i, j, total_weight, count=0;

            cout<<”The names are:”<<endl;

            for(i=0;i<12;i++)

            {

                        cout<<name[i]<<endl;

            }

            cout<<”The Weihts are:<<endl;

            for(i=0;i<12;i++)

            {

                        cout<<weight[i]<<endl;

            }

            cout<<”The list of people who are eligible to take Lift:”<<endl;

            for(i=0;i<12;i++)

            {

                        total_weight=weight[i];

                        new_name[i]=name[i];

                        for(j=i+1;j<12;j++)

                        {

                                    

if(total_weight<=1100)

                                    {

                                                total_weight=total_weight+weight[j];

                                                new_name[i++]=name[j];

                                                count++;

                                    

                                    }

                        }

                        for(k=0;k<count;k++)

                        {

                                    cout<< new_name[k]<<endl;

                        }

                        cout<<”The total Weight is: “<<total_weight<<endl;

                        cout<<”The total number of people: “<<count<<endl;

            }

            return 0;

}

Note: First and Second Part is done.

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