Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**C++ make this code past this test bellow, please I WILL UPVOTE! Thank you /* Program to read student data from file and store in

**C++ make this code past this test bellow, please I WILL UPVOTE! Thank you

/* Program to read student data from file and store in parallel arrays Then sort by ID and GPA Store them separately corresponding arrays Then do some operations through menu */ #include #include #include #include using namespace std; //Function prototypes int readFile(ifstream&in, int netID[], string major[], double GPA[], const int MAX); void copyData(const int netID[], const string major[], const double GPA[], int sortedNetID[], string sortedMajor[], double sortedGPA[],const int cnt); void modifiedSortGPA(int sortedNetID[], string sortedMajor[], double sortedGPA[], const int cnt); void modifiedSortID(int sortedNetID[], string sortedMajor[], double sortedGPA[], const int cnt); void displayArray(const int netID[], const string major[], const double GPA[], const int cnt); void displayArrayByGPA(const int netID[], const string major[], const double GPA[],const int max, const int cnt); int menu(); int linearSearchID(int arr[], int numElements, int value, int &nIter); int binarySearchID(int arr[], int numElements, int value, int &nIter); int main() { //Declare maximum students count const int NUM_LIMITS = 18; //Variable for count of students display int n,id,nIter=0; //Parrallel arrays for students details store int netID[NUM_LIMITS]; string major[NUM_LIMITS]; double GPA[NUM_LIMITS]; //Arrays to store sorted by GPA int sortedNetIDbyGPA[NUM_LIMITS]; string sortedMajorbyGPA[NUM_LIMITS]; double sortedGPAbyGPA[NUM_LIMITS]; //Arrays to store sorted by netId int sortedNetIDbyID[NUM_LIMITS]; string sortedMajorbyID[NUM_LIMITS]; double sortedGPAbyID[NUM_LIMITS]; //Variable to read file name string fileName; //Prompt for filename cout > fileName; //File read object set ifstream in(fileName); //File open error check if (!in) { cout > n; if (n >= studentCnt) { cout > id; int ind = linearSearchID(netID, studentCnt, id, nIter); cout > netID[i] >> major[i] >> GPA[i]; i++; } return i; } /* Function use to copy arrays baseto parrallel corresponding arrays */ void copyData(const int netID[], const string major[], const double GPA[], int sortedNetID[], string sortedMajor[], double sortedGPA[],const int cnt){ //Copy data for (int i = 0; i sortedGPA[j]) { double gpa = sortedGPA[i]; int id = sortedNetID[i]; string major = sortedMajor[i]; sortedGPA[i] = sortedGPA[j]; sortedNetID[i] = sortedNetID[j]; sortedMajor[i] = sortedMajor[j]; sortedGPA[j] = gpa; sortedNetID[j] = id; sortedMajor[j] = major; } } } } /* Function to sort parrallel arrays using ID Use bubble sort */ void modifiedSortID(int sortedNetID[], string sortedMajor[], double sortedGPA[], const int cnt) { for (int i = 0; i sortedNetID[j]) { double gpa = sortedGPA[i]; int id = sortedNetID[i]; string major = sortedMajor[i]; sortedGPA[i] = sortedGPA[j]; sortedNetID[i] = sortedNetID[j]; sortedMajor[i] = sortedMajor[j]; sortedGPA[j] = gpa; sortedNetID[j] = id; sortedMajor[j] = major; } } } } /* Function to display array data */ void displayArray(const int netID[], const string major[], const double GPA[], const int cnt) { cout > opt; while (opt 3) { cout > opt; } return opt; } /* Function display data according to option1 */ void displayArrayByGPA(const int netID[], const string major[], const double GPA[],const int max, const int cnt) { int j = 0; for (int i = max-1; i>=0; i--) { if (j

mid = (low + high) / 2; if (value arr[mid]){ low = mid + 1; nIter++; }

}while (value != arr[mid] && low

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

input Qur outgut correcty starts with It Tesing an Bnter file nane: Original arkay?: Arrayn sorted by Gest Drrays- ported by fietio- Henu ot chateen 1-Livtiropaesadents2-Siecehan*netrn3-guitZuicing ArtayzaresdtyGDh Menu of choices 1 - List top n n tudents 2 - Search on a netID 3. Quit Exiting Arrayg sorted by GPA: \begin{tabular}{|r|rrrrrrrr} \hline Your output does not & index netID & major & GPA & index & netID & major & GPA \\ contain & 0 & 1031 & ME & 2.90 & 1 & 1038 & ME & 3.00 \\ & 2 & 1043 & EE & 3.10 & 3 & 1013 & CS & 3.20 \\ & 4 & 1025 & CS & 3.30 & 5 & 1061 & CS & 3.50 \\ & 6 & 1048 & BME & 3.70 & 7 & 1018 & BME & 3.75 \\ & 8 & 1007 & ME & 3.80 & 9 & 1054 & CS 3.95 \end{tabular} Output differs. See highlights below. Outgut dffets Sent nigh ohes declow. anl-sice input is. 12 3 Menu of ehosces 1.Hisetopnatudents2-Seatehonynetto.3-QutDetFP:1054,mejor.CS,CFK=3.25fotID:101h,major;iMat,GPh:3.7IHet1D:1069,nader:Elf.GPA5.T0netlD:10E1,mijortGS,GPAZ.JonetID-1025,nayoEC3,90PN,3,30betibeto1.,majes,cs,GPA:3.20net1ot1043,hajog:Rz,Gehi3.20.Eet1P1035,Masor:10,GPK:1.04nectDA10J1,majoyMA.GPR.2.90. Meau of elosicen 1 - ilut top nn zbodents 2 - Pearch an t netrp 1 - Gaie Eatting Menes of chaderex 1. - Liat pop n atudens: - Sapreh on a necto 3. Guit Rntex n : Top 18 stidest are: netioti-te54,majot:GJ,GPd:3.25nectot:1007,majer:HE,CDA:3,00netth1040,meseritiex.GDh3.70 Outgut dffets Sent nigh ohes declow. anl-sice input is. 12 3 Menu of ehosces 1.Hisetopnatudents2-Seatehonynetto.3-QutDetFP:1054,mejor.CS,CFK=3.25fotID:101h,major;iMat,GPh:3.7IHet1D:1069,nader:Elf.GPA5.T0netlD:10E1,mijortGS,GPAZ.JonetID-1025,nayoEC3,90PN,3,30betibeto1.,majes,cs,GPA:3.20net1ot1043,hajog:Rz,Gehi3.20.Eet1P1035,Masor:10,GPK:1.04nectDA10J1,majoyMA.GPR.2.90. Meau of elosicen 1 - ilut top nn zbodents 2 - Pearch an t netrp 1 - Gaie Eatting Menes of chaderex 1. - Liat pop n atudens: - Sapreh on a necto 3. Guit Rntex n : Top 18 stidest are: netioti-te54,majot:GJ,GPd:3.25nectot:1007,majer:HE,CDA:3,00netth1040,meseritiex.GDh3.70 netID: 1031 , major: ME, GPA: 2.90 netI: B90934720, major: \&. GPA: 0.00 Menu of chotces 1 - List top n geudents 2 - Search on a netID 3 - Quit Exiting Artazs iorted by oph: Arrava arted by netion Menu of chatest B. Tint: sop 7 atpdats: 2. Sestep on mint: 3.rin duit: Enese nestor Peeste of lines mareh Stladents founat of thdek Gi GD. in +20 In took 1 icerovions Sredant fouth at inchis of gm L. I. Se It fosk if ntwatcing Dherad of cisatwe 1. Atwi crip in mipeses if Searuh an oulto: Meny of ehotees Putput differs see highlosits below. index netio mayer GDh index necTD aajor GD Menu of chalces. 1) - Liat rop a asudensa 2 - Search on a nerto 3- - pute Tater butto? Eerult of isnes aearch Frodent not tound If togit 11 iteration: Pinu1t of banarypiacti seacch Studect not found if took 1 iteritions Mend of chaicen 1-Liatvoponitudent2-iearchonapetto3-Qutt.Latsing Totat fili natel Original arzaye Mrraya es+ted by abd: 1. Selreh on a netio 3. Duit Muriting Bitez tili mand: oxiginal arrayaz Asfaye sorted by GPa: Arrays jorted by nectl: Henu of chatces 1- Hast topia ntudenis 2 - Seateh on a netit? 3 - Quif Inter netID Result of linewr surch Geadent nof found It eooly 1 fi iterationy Ravule of bimbry wearch? Ntudent not found To took /i irefation 1Sima of thotoea 1 - Llat fog n asudents 1. If Semrah on a netID 7. a puth Ixiedray main, opp: In function hool teutpussed (xtdsiotstreamb) 'A 42 modifiedsotefobrray2, atrayd, array3, 6) ? main.cppis:47: note: initializing argument 2 of tyoid modifiedsortid 2e. void modiftedgortID (Int, sortedelerto i, string nortedgajortl, dot

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

Does your product/program have a descriptive and memorable slogan?

Answered: 1 week ago

Question

How does this compare with the Fog Index for your written message?

Answered: 1 week ago