Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

General Instructions : Read the problem description below and reorganize this program in C++. The files for this assignment are provided under the folder for

General Instructions: Read the problem description below and reorganize this program in C++. The files for this assignment are provided under the folder for this assignment. You will be submitting two separate projects. See Part A and Part B for details.

  • All of the functions making up this program are complete and in working order except for functions marked with /// FILL THIS FUNCTION. You will need to implement these functions.
  • The major challenge in this assignment is to divide the program into separately compiled modules.
    • A candidates module with files candidates.h and candidates.cpp, containing code dealing specifically with manipulating the reservations array.
    • A openings module, consisting of files openings.h and openings.cpp containing code dealing specifically with the opening position records.
    • An optional general functions module with the files generalFunctions.h and generalFunctions.cpp containing code that is not specifically geared towards candidates or openings.
    • Consult the comments in the provided code for additional details.
    • There are some functions that are not specifically related to any of these modules, but are called by or contain code needed by certain modules You should apportion these functions to the modules in a way consistent with the goals of high cohesion.

Problem description:

A new startup company has been left without a database after a falling out with the previous database administrator. As an intern, you have decided to impress management by creating a program that uses some of those files to aid company recruiters in managing openings and potential candidates. The program must have the following options: Add Opening, Delete Opening, Show Openings, Match Candidates with all Openings, Add Candidate, Show Candidates, Show Candidates by Position, Filter Candidates By Rating, and Clear Screen.

Input

Input to the program is taken from several text files containing data regarding job openings and registered candidates. These are included, but your program should function even if the information in the data files were to change with the format being the same. The first line in every file is the number of data points (lines) in the file.

Output

The output should be regular updates to the 2 files, as well as interactive menus display the file contents.

Part A:

Create a project containing the file main.cpp. Implement the empty functions marked with ///Fill This Function comments. You will need understand the purpose of these function in order to implement them. Do this by looking for where the functions are being called and how the function is being used in the program. Also, there may be other function that do similar, though not the same task. These functions may give you a clue how to implement the empty functions.

The program should compile and have expected Input and Output as outlined above. You will not need to split the functions into modules for part A.

Part B:

Create a project containing the files main.cpp, candidates.cpp, candidates.h, openings.cpp, openings.h, generalFunctions.cpp, generalFunctions.h. Split the functions from Part A into the appropriate modules as outlined in the general instructions. The program should compile and have the same input and output as Part A. In order to determine where a function belongs, look to see what functions it calls, and which functions it is called by. Functions which rely heavily on each other are good candidates for a module. Functions which are associated in purpose may also be candidates for a particular module.

openings.txt

13 0 manager production 3 VA yes 10 1 analyst purchasing 2 PA yes 5 2 assistant marketing 1 VA no 2 3 administrator accounting 2 FL yes 7 4 lawyer HR 2 NY yes 3 5 developer R_D 1 CA yes 1 6 receptionist marketing 1 VA no 1 7 clerk accounting 1 PA no 1 8 buyer purchasing 2 FL no 2 9 worker production 1 NY yes 5 10 clerk production 1 CA no 1 11 coordinator HR 3 VA no 1 12 driver production 1 VA yes 8 

candidates.txt

21 John Taylor developer 65000 4.5 7573938284 William Smith engineer 75000 3.9 7203020381 Mary Baker engineer 76000 4.1 5838348363 Henry Caves lawyer 90000 4.9 2838232084 John Billson clerk 50000 4.3 4873820948 Kostas Olgenson accountant 53000 3.2 4232432966 Mark Miller administrator 79000 3.4 4234829124 Brock Johnson worker 45000 4.1 2393971642 Jennifer Stein buyer 64000 4.4 3746549091 Eric Moore buyer 69000 2.9 3847279910 Jessica Dowes coordinator 80000 3.7 4027651909 Eric Selic manager 80000 4.1 8470981347 Sarah Bronn developer 63000 3.5 9382931383 Justin Hawkings purchasing 69000 3.3 8982987656 Scott Johansson engineer 65000 3.9 7570987671 Michael Willberg manager 98000 5 7570901231 Terry Berg worker 49000 3.1 9098976540 Alee Matz assistant 60000 2.6 7573230838 Jason Freedman assistant 65000 3.4 4343243234 Alex Tsi chief 90000 1.1 7571111111 Marylin Scott manager 85000 4.1 7578995090 

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 transcribed

1 2 3 4 5 6 7 #includeiostream include #include ioma nip #include #include // for string streams #include stdlib.h> using namespace std; void Menu string IntToString (int i) int StringToInt (string s void AddOpening(string openings [] [7], int size); void PrintOpenings (string openings [] [71, int size) void Loadopenings (ifstream& infile, string openings [1 [71, int num openings) void DeleteOpening (string openings [] [71, int size) void Getopening (string opening I71) void SaveOpenings (string openings I71, int size) void ResetIDs (string openings [] [7], int size) void swapItems (string openings [1 [7, int indexA, int indexB) void FindHatches (atring candidates , int cand_size, string openings[][7], int opening_size) void GetCandidate (string candidate [1 void SaveCandidates (string temp 1, int size) void LoadCandidates (ifstream& infile, string candidates[] [], int num_candidates) void AddCandidate (string candidates [1 , int size); void ShowCandidatesByPosition (string candidates], int size) void PrintCandidates (string candidates] 6], int size) void SwapCandidates (string candidates 1, int indexA, int indexB) void SortByRating (string candidates[l [], int num candidates, int rating)i void FilterCandidatesByRating(string candidates[l le], int num candidates) void PrintCandidate (string temp[ , int index) 10 12 13 15 16 17 18 19 20 21 23 24 25 28 27 28 29 30 31 32 int main) 34 35 36 37 38 39 40 41 Menu return 0 //loads the contents of the candidates array in a 2D string array called candidates /ew 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 cal void LodCandidates (ifstream& infile, string candidates[] [], int num_candidates) 43 FILL THIS FUNCION 45 46 47 48 49 50 51 52 53 54 void AddCandidate (atring candidates ] [, int size) string newCandidate ] GetCandidate (newCandidate) string temp [sizetl] [1 for (int i-; i>temp candidate [01-temp cout>temp: candidate [1]-temp couttempi candidate [2] temp cout temp: candidate [3]-temp cout>temp; candidate [41-tempi cout>temp; candidate IS1-temp: 7 68 69 70 71 72 73 74 75 76 78 79 80 82 83 84 85 86 87 void SaveCandidates (string temp[ ], int size) 89 90 ofstream outfile: 91 92 93 94 95 9 97 98 outfile.open("candidates.xt", ios::out) outfilecandidates Ij+1] [4]) SwapCandidates (candidates, j j+1) PrintCandidates (candidates, num candidates) void FilterCandidatesByRating(string candidatesl , int num candida int rating GetRating cout>rating if (cin.failtrue rating 5) system"CLS") cout'Invalid Input " endl ; cin.clear cin.ignore (10000, n') goto GetRating: 172 173 174 175 176 int counter-0 string temp; for (int i-0 i= rating 181 182 183 184 185 18 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 countertt string f cand Icounter] [6] int copied-0 while(copied >= rating) E_cand[copied] [k]-candidatesi] k]: copied+t: SortByRating_cand, counter)i void PrintCandidate (string candidates [][E], int index) for ( int j=0; j 6; j++) cout openings [i]ljli 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 27 268 29 270 void PrintOpenings (string openings [1 17], int size) >del id if (cin, fail()=-true II del id 0 II del id > (size-1)) system("CLS") cout"Invalid Input "endl ; cin.clear) cin.ignore (10000, n goto getId; if (delid !#0) //as long as ID inputted is not 0 int newSizesize-l for (int i-del id ; size-1; //decrease the size i++) swapItems (openings, i, i+l)/and swap all elements above our deletion ID eseIDs(openings, nevSize) SaveOpenings (openings, newSize)//giving size-1 disregards the Last element in the process, which has been swapped on the previous step 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 else system"CLS" //Used for openings void swapItems (string openings] [7], int indexA, int indexB) FILL THIS FUNCTION void Getopening (string opening[71) //ve keep re-aa values to this temp variable string tempi coutccendlccendli cout>temp opening I1]-temp cout>temp opening [ 3 ] =temp cout>temp opening I5]-temp cout(setw (45)>temp openingI1-temp /store temp value to its place in the array void SaveOpenings (string openings 7, int size) ofstream outfile outfile, open ("openings,"", outfile integer return integer /Ithis converts integers to strings string IntToString (int i) ostringstream strli string temp = stri, str(); return temp //Receives input from the user and performs appropriate command /all operations require constant reading and wziting of files void Menu ) int input 361 362 ifstream inOpenings int nu openings ifatream inCandidatesi int num candidates //this variable vil1 allow input operations Eor the openings file 364 365 366 367 368 39 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 //this vaziable vil1 a11ow input operations Eor the candidates Eile redo we need to load every time inopenings.open ("openings xt", ios::in) //open files inopenings>num_openings; inCandidates. open ( "candidates.&", ios: : in); inCanddidatesnum candidates //read # of entries in file atring openings [num openingsi 71 string candidates [numcandidates] [E] Loadopenings (inopenings, openings, num openings) LoadCandidates (inCandidates, candidates, num candidates) inOpenings.close //close the files inCandidates.close) /czeate azzay to stoze info cuzzently in ile this loads the contents to the azray, so that we can use it in subsequent operations GetSelection //This is a label, a destination for a goto statement. Allows us to reenter the menu without nga whiLe cout "I coutc"2 "setw 40) std: left>input if (cin.failtrue input> S) system("CLS") cout #include ioma nip #include #include // for string streams #include stdlib.h> using namespace std; void Menu string IntToString (int i) int StringToInt (string s void AddOpening(string openings [] [7], int size); void PrintOpenings (string openings [] [71, int size) void Loadopenings (ifstream& infile, string openings [1 [71, int num openings) void DeleteOpening (string openings [] [71, int size) void Getopening (string opening I71) void SaveOpenings (string openings I71, int size) void ResetIDs (string openings [] [7], int size) void swapItems (string openings [1 [7, int indexA, int indexB) void FindHatches (atring candidates , int cand_size, string openings[][7], int opening_size) void GetCandidate (string candidate [1 void SaveCandidates (string temp 1, int size) void LoadCandidates (ifstream& infile, string candidates[] [], int num_candidates) void AddCandidate (string candidates [1 , int size); void ShowCandidatesByPosition (string candidates], int size) void PrintCandidates (string candidates] 6], int size) void SwapCandidates (string candidates 1, int indexA, int indexB) void SortByRating (string candidates[l [], int num candidates, int rating)i void FilterCandidatesByRating(string candidates[l le], int num candidates) void PrintCandidate (string temp[ , int index) 10 12 13 15 16 17 18 19 20 21 23 24 25 28 27 28 29 30 31 32 int main) 34 35 36 37 38 39 40 41 Menu return 0 //loads the contents of the candidates array in a 2D string array called candidates /ew 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 cal void LodCandidates (ifstream& infile, string candidates[] [], int num_candidates) 43 FILL THIS FUNCION 45 46 47 48 49 50 51 52 53 54 void AddCandidate (atring candidates ] [, int size) string newCandidate ] GetCandidate (newCandidate) string temp [sizetl] [1 for (int i-; i>temp candidate [01-temp cout>temp: candidate [1]-temp couttempi candidate [2] temp cout temp: candidate [3]-temp cout>temp; candidate [41-tempi cout>temp; candidate IS1-temp: 7 68 69 70 71 72 73 74 75 76 78 79 80 82 83 84 85 86 87 void SaveCandidates (string temp[ ], int size) 89 90 ofstream outfile: 91 92 93 94 95 9 97 98 outfile.open("candidates.xt", ios::out) outfilecandidates Ij+1] [4]) SwapCandidates (candidates, j j+1) PrintCandidates (candidates, num candidates) void FilterCandidatesByRating(string candidatesl , int num candida int rating GetRating cout>rating if (cin.failtrue rating 5) system"CLS") cout'Invalid Input " endl ; cin.clear cin.ignore (10000, n') goto GetRating: 172 173 174 175 176 int counter-0 string temp; for (int i-0 i= rating 181 182 183 184 185 18 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 countertt string f cand Icounter] [6] int copied-0 while(copied >= rating) E_cand[copied] [k]-candidatesi] k]: copied+t: SortByRating_cand, counter)i void PrintCandidate (string candidates [][E], int index) for ( int j=0; j 6; j++) cout openings [i]ljli 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 27 268 29 270 void PrintOpenings (string openings [1 17], int size) >del id if (cin, fail()=-true II del id 0 II del id > (size-1)) system("CLS") cout"Invalid Input "endl ; cin.clear) cin.ignore (10000, n goto getId; if (delid !#0) //as long as ID inputted is not 0 int newSizesize-l for (int i-del id ; size-1; //decrease the size i++) swapItems (openings, i, i+l)/and swap all elements above our deletion ID eseIDs(openings, nevSize) SaveOpenings (openings, newSize)//giving size-1 disregards the Last element in the process, which has been swapped on the previous step 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 else system"CLS" //Used for openings void swapItems (string openings] [7], int indexA, int indexB) FILL THIS FUNCTION void Getopening (string opening[71) //ve keep re-aa values to this temp variable string tempi coutccendlccendli cout>temp opening I1]-temp cout>temp opening [ 3 ] =temp cout>temp opening I5]-temp cout(setw (45)>temp openingI1-temp /store temp value to its place in the array void SaveOpenings (string openings 7, int size) ofstream outfile outfile, open ("openings,"", outfile integer return integer /Ithis converts integers to strings string IntToString (int i) ostringstream strli string temp = stri, str(); return temp //Receives input from the user and performs appropriate command /all operations require constant reading and wziting of files void Menu ) int input 361 362 ifstream inOpenings int nu openings ifatream inCandidatesi int num candidates //this variable vil1 allow input operations Eor the openings file 364 365 366 367 368 39 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 //this vaziable vil1 a11ow input operations Eor the candidates Eile redo we need to load every time inopenings.open ("openings xt", ios::in) //open files inopenings>num_openings; inCandidates. open ( "candidates.&", ios: : in); inCanddidatesnum candidates //read # of entries in file atring openings [num openingsi 71 string candidates [numcandidates] [E] Loadopenings (inopenings, openings, num openings) LoadCandidates (inCandidates, candidates, num candidates) inOpenings.close //close the files inCandidates.close) /czeate azzay to stoze info cuzzently in ile this loads the contents to the azray, so that we can use it in subsequent operations GetSelection //This is a label, a destination for a goto statement. Allows us to reenter the menu without nga whiLe cout "I coutc"2 "setw 40) std: left>input if (cin.failtrue input> S) system("CLS") cout

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

Step: 3

blur-text-image

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

Find the z value that corresponds to the given area. 0.4175

Answered: 1 week ago