Question
C++ : This software stores all the data in array . Each person has SSN and name information. This information is provided in separated files.
C++ :
This software stores all the data in array. Each person has SSN and name information. This information is provided in separated files.
This is the data of a sample file:
i 586412373 NICOLA EVANGELISTA i 177228167 MEAGAN LEKBERG i 586412373 JEFF DUTTER i 760846483 KITTY MANZANERO i 061899135 CATHERIN MCCREIGHT i 087300880 CARMA KULHANEK i 177264549 VALERY KOSAKOWSKI i 210044984 SHEILAH MONGES d 760846483 KITTY MANZANERO r 760846483 KITTY MANZANERO r 007980295 DELPHIA SIMISON i 493515916 VERONIKA TADENA d 401991909 MCKINLEY WESTERFELD i 793267575 TEMIKA MESHEW i 319373939 MARGIT EBLIN
In above file, each row represents one persons information. The leading character is either i, d, or r. The second column is the SSN of the person, the following string are the first name and last name.
This project will provide the basic following operations for the data in the array:
Insertion. The software adds the data to the end of the data in the array. If the provided data has duplicated SSN with an existing entry, the software will discard the provided data. Otherwise, increase the insertion counter by one.
Delete. The software deletes the entry with given SSN and name from the array. It is possible that provided SSN does not match any record in the array, if that is the case, the software ignor this deletion request. If there is a match in the array, delete the record from the array, increase the delete counter by one.
Retrieval. The software searches the given SSN and name in the array. If the there is a match in the array, increase the retrieval counter by one.
Specifications
-The software should process the information row-by-row, from the beginning to the end of the file.
-The character i means insertion. The software should insert the SSN and name to the end of the data in the array. However, the software will NOT insert personal information with duplicate SSN. For example, the first row and the third row have duplicate SSN. The information of the first person will be added, but the third will not.
-The character d means deletion. In this example, there are two d rows. The first one has SSN 760846483, which matches the fourth row. The corresponding record in the array will be deleted, the following records will be moved up by one position. The second d row does not match any existing SSN, the information of this row will be ignored.
-The character r means retrieval. If there is a match with the given SSN, increase the retrieval counter by one. In the above example, there are two r rows. The first one has a match, the second one does not have match.
In this project, we store the data in the array. Here are several requirements for the array:
-The initial size of the array is 1000.
-When you add a new entry to the array, if the array is not full, add the entry. If the array is full, creates a new array with doubled size. Copy the data from the old array to
the new array. Release the old array.
-When you delete an entry from the array. If the number of entry is less than 14 of the array size. Creates a new array with half size of the current array.
Copy the data from the old array to the new array, then release the old array.
AN EXAMPLE OF RUNNING PROGRAM
ashk ./a.out 15-idr
The Number of Valid Insertation :10 The Number of Valid Deletion :1 The Number of Valid Retrieval :0
Item numbers in the Array Size is :9
Array Size is :500
TIPS:
-retrive() method which checks whether the given SSN and name matches entry in the array. If there is a match, increase the retrival count by one.
-insert() method which inserts data to the end of the array. If the provided data has duplicated SSN with an existing entry, the software will discard the provided data. Otherwise, increase the insertion counter by one.
-deletion() method which the software deletes the entry with given SSN and name from the array. It is possible that provided SSN does not match any record in the array, if that is the case, the software ignore this deletion request. If there is a match in the array, delete the record from the array, increase the delete counter by one.
-main() method:
int main(int argc, const char * argv[]) { fstream input(argv[1]);
.
.
.
while(!input.eof()){ input }
cout << "The Number of Valid Insertation :" << endl; cout << "The Number of Valid Deletion :" << endl; cout << "The Number of Valid Retrieval :" << endl; cout << "Item numbers in the array :" << endl; cout << "Array Size is :" << endl;
}
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