Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need Help With The Void addOpenings function Thank you in advance! #include #include #include #include #include // for string streams #include using namespace std; void
Need Help With The "Void addOpenings" function
Thank you in advance!
#include#include #include #include #include // for string streams #include using namespace std; void Menu(); string IntToString(int i); int StringToInt(string s); void AddOpening(string openings[][7], int size); void PrintOpenings(string openings[][7], int size); void LoadOpenings(ifstream& infile, string openings[][7], int num_openings); void DeleteOpening(string openings[][7], int size); void GetOpening(string opening[7]); void SaveOpenings(string openings[][7], int size); void ResetIDs(string openings[][7], int size); void swapItems(string openings[][7], int indexA, int indexB); void FindMatches(string candidates[][6], int cand_size, string openings[][7], int opening_size); void GetCandidate(string candidate[6]); void SaveCandidates(string temp[][6], int size); void LoadCandidates(ifstream& infile, string candidates[][6], int num_candidates); void AddCandidate(string candidates[][6], int size); void ShowCandidatesByPosition(string candidates[][6], int size); void PrintCandidates(string candidates[][6], int size); void SwapCandidates(string candidates[][6], int indexA, int indexB); void SortByRating(string candidates[][6], int num_candidates); void FilterCandidatesByRating(string candidates[][6], int num_candidates); void PrintCandidate(string temp[][6], int index); int main() { Menu(); return 0; } //loads the contents of the candidates array in a 2D string array called candidates //num candidates is the number of entries in the files, must be provided as a parameter //meaning that the file is opened at least ones before callign this function void LoadCandidates(ifstream& infile, string candidates[][6], int num_candidates) { ///FILL THIS FUNCION } void AddCandidate(string candidates[][6], int size) { string newCandidate[6]; GetCandidate(newCandidate); string temp[size+1][6]; for(int i=0; i >temp; candidate[0]=temp; cout< >temp; candidate[1]=temp; cout< >temp; candidate[2]=temp; cout< >temp; candidate[3]=temp; cout< >temp; candidate[4]=temp; cout< >temp; candidate[5]=temp; } void SaveCandidates(string temp[][6], int size) { ofstream outfile; outfile.open("candidates.txt", ios::out); outfile< >position; if(cin.fail()==true) { system("CLS"); cout<<"Invalid Input"< candidates[j+1][4]) SwapCandidates(candidates, j, j+1); PrintCandidates(candidates, num_candidates); } void FilterCandidatesByRating(string candidates[][6], int num_candidates) { int rating; GetRating: cout<<"Enter minimum Rating(1-5): "; cin>>rating; if(cin.fail() == true || rating<1 || rating> 5) { system("CLS"); cout<<"Invalid Input"< = rating) counter++; } string f_cand[counter][6]; int copied=0; while(copied = rating) { for(int k=0; k<6; k++){ f_cand[copied][k]=candidates[i][k]; if (counter == 1){ PrintCandidate(candidates, i); return; } } copied++; } } } SortByRating(f_cand, counter); } void PrintCandidate(string candidates[][6], int index) { for(int j=0; j<6; j++) cout< >openings[i][j]; } } void PrintOpenings(string openings[][7], int size) { cout< >del_id; if(cin.fail()==true || del_id < -1 || del_id > (size-1)) { system("CLS"); cout<<"Invalid Input"< >temp; opening[1]=temp; //store temp value to its place in the array cout< >temp; opening[2]=temp; cout< >temp; opening[3]=temp; cout< >temp; opening[4]=temp; cout< >temp; opening[5]=temp; cout< >temp; opening[6]=temp; } void SaveOpenings(string openings[][7], int size) { ofstream outfile; outfile.open("openings.txt", ios::out); //opens the file for writing purposes outfile< > integer; return integer; } //this converts integers to strings string IntToString(int i) { ostringstream str1; str1<>num_openings; //read # of entries in file inCandidates.open("candidates.txt", ios::in); inCandidates>>num_candidates; string openings[num_openings][7]; //create array to store info currently in file string candidates[num_candidates][6]; LoadOpenings(inOpenings, openings, num_openings); //this loads the contents to the array, so that we can use it in subsequent operations LoadCandidates(inCandidates, candidates, num_candidates); inOpenings.close(); //close the files inCandidates.close(); GetSelection: //This is a label, a destination for a goto statement. Allows us to reenter the menu without writing a while loop cout<<"1. "< >input; if(cin.fail() == true || input>9) { system("CLS"); cout<
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started