Question: #include #include #include #include // this header is required for the manipulation of the input and output format using namespace std; int searchlinear(int arr[],int id,

![of the input and output format using namespace std; int searchlinear(int arr[],int](https://s3.amazonaws.com/si.experts.images/answers/2024/08/66cd1b5182205_90566cd1b510b7e4.jpg)
#include #include #include #include // this header is required for the manipulation of the input and output format using namespace std; int searchlinear(int arr[],int id, int size) { int i; for (i= 0; i >f_name; ifstream stufile(f_name.c_str()); if (stufile.is_open()) { while (stufile>>line) { netID[i]=stoi(line); stufile>>line; major[i]=line; stufile>>line; GPA[i]= stod(line); i++; } stufile.close(); for(j=0;j { sortedNetIDbyGPA[j]=netID[j]; sortedGPAbyGPA[j]=GPA[j]; sortedMajorbyGPA[j]=major[j]; sortedNetIDbyID[j]=netID[j]; sortedGPAbyID[j]=GPA[j]; sortedMajorbyID[j]=major[j]; } // sorting by GPA for (j = 0; j sortedGPAbyGPA[max]) max=k; swapGPA=sortedGPAbyGPA[max]; sortedGPAbyGPA[max]=sortedGPAbyGPA[j]; sortedGPAbyGPA[j]=swapGPA; swapmajor=sortedMajorbyGPA[max]; sortedMajorbyGPA[max]=sortedMajorbyGPA[j]; sortedMajorbyGPA[j]=swapmajor; swapID=sortedNetIDbyGPA[max]; sortedNetIDbyGPA[max]=sortedNetIDbyGPA[j]; sortedNetIDbyGPA[j]=swapID; } // sorting by swapID for (j = 0; j >choice; if(choice==1) { cout>n; for(j=0;j { cout>ID; index=searchlinear(netID, ID,i); if(index>=0) { cout} else cout=0) { cout } else cout
***This is my code but I keep getting this error. My output should look exactly like the "expected output starts with" in the last picture. but for some reason my output has extra stuff like the sorted array by GPA and the sorted array by id.
This is my input files:
in1.txt
1007 ME 3.8 1013 CS 3.2 1018 BME 3.75 1025 CS 3.3 1031 ME 2.9 1038 ME 3 1043 EE 3.1 1048 BME 3.7 1054 CS 3.95 1061 CS 3.5
in2.txt
1000 CS 3.7 2000 CE 3.2 3000 ME 3.0 4000 BME 3.4 5000 CS 3.5
in3.txt
1000 CS 3.7 2000 CE 3.2 3000 ME 3.0 4000 BME 3.4 5000 CS 3.5 6000 ME 3.1
C st Hemewnk Help Wwthc zy 2.1. H1 hi ybouk/UICALLASC 133 90313311 133 zyBooks My library CE 1337/CS 1337/TE 1337: Compuler Science I home 2.1: Hw yBooks catalogHelp/FAO safan al in1.txt Input Enter file na Original arrays: index netID major GPA index netID major CPAe cs 3.20d ME 3.30 2 1018 BME 3.75 ME 2.90 EE 3.10 Cs 3.95 1 1013 3 1025 5 1038 7 1048 BME 3.70 9 1061 Cs 3.50e 1007 CS 3.30e ME 3.00 4 1031 6 1043 1054 Sorted aray by GPA index netID major GP index netID major GPA 0 1007 ME 3.901013 Cs 3.20 Your output starts with 1018 B 3.75 1025 S 3.30 ME 3.00 BME 3.T0 8 1054 3.95 9 1061 s 3.500 4 1031 1043 ME 2.90 EF 3.1 5 1036 1048 O lype hene to search C st Hemewnk Help Wwthc zy 2.1. H1 hi ybouk/UICALLASC 133 90313311 133 zyBooks My library CE 1337/CS 1337/TE 1337: Compuler Science I home 2.1: Hw yBooks catalogHelp/FAO safan al i ndax net.TD ma jor GPA index net.TD major GPA 1013 1025 0 1007 Your output starts with ME 3.90 BME 37 Cs 3.20e S 3.304 101 031 2.93) EE 3.1 8 1054 3.95 9 1061 5 1038 1043 7 104 BME 3.7 3.50 sorted array by LD index netID 1007 ndex netID major GPA 1013 CS 3.20 ME 3.30 CS 3.30e 6 1043 EE 3.10 CS 3.95 7 1048 9 1061 BME 3.70 Cs 3.50 8 1054 1. List Enter file name: Original arrays: i ndexnet.TD jor GPAidex net.TD major GPA cs 3.20 Expected output 0 1007 ME 3.80 1 1013 O lype hene to search hi ybouk/UICALLASC 133 90313311 133 zyBooks My library CE 1337/CS 1337/TE 1337: Compuler Science I home 2.1: Hw ryBooks calalog ) Help/FAQ saran ali rted arra index netID major GPA index netID major GPA 1013 CS 3.20 0 1007 CS 3.30 6 1043 EE 3.10 CS 3.9 1048 BME 3.TO 8 1054 9 106 CS 3.50 1. List Ent.er file name: Original arrays: Expected output starts with index netID major GPA indextID major GPA CS 3.20 CS 3.30 0 1007 1018 1031 6 1043 8 1054 ME 3.80 1 1013 BME 3.75 3 1025 C 3.3 5 103 ME EE 3.10 CS 3.95 ME 1048 ME 3.70 91061 cs 3.50 : Output-3 0/13 O lype hene to search
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
