diff options
| author | BensProgramma <[email protected]> | 2021-12-06 15:07:43 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-06 15:07:43 -0800 |
| commit | 06070ec9d7afc2f35dc2e17e7f39dd2424270520 (patch) | |
| tree | b23caa4c2ae9f8ad86c0eb8802d488116d2edde2 /CST116F2021-Lab9/CST116F2021-Lab9_Schroeder.cpp | |
| parent | Delete INFO2.txt (diff) | |
| download | cst116-lab9-bensprogramma-06070ec9d7afc2f35dc2e17e7f39dd2424270520.tar.xz cst116-lab9-bensprogramma-06070ec9d7afc2f35dc2e17e7f39dd2424270520.zip | |
Update CST116F2021-Lab9_Schroeder.cpp
Diffstat (limited to 'CST116F2021-Lab9/CST116F2021-Lab9_Schroeder.cpp')
| -rw-r--r-- | CST116F2021-Lab9/CST116F2021-Lab9_Schroeder.cpp | 50 |
1 files changed, 15 insertions, 35 deletions
diff --git a/CST116F2021-Lab9/CST116F2021-Lab9_Schroeder.cpp b/CST116F2021-Lab9/CST116F2021-Lab9_Schroeder.cpp index 37a80ee..6aac72e 100644 --- a/CST116F2021-Lab9/CST116F2021-Lab9_Schroeder.cpp +++ b/CST116F2021-Lab9/CST116F2021-Lab9_Schroeder.cpp @@ -175,52 +175,32 @@ void DisplayMenu() void Find() - { - /*int SearchBy = 0; - cout << "1) Last Name: "; - cout << "2) First Name: "; - cout << "3) ph #: "; - cout << "4) Date Of Birth: "; - cout << "Which field would you like to search by? (Enter a # 1 thru 4)"; - cin >> SearchBy;*/ - - Sort(); - string subString = ""; - - cout << "Enter the Last Name of the person whose account you wish to see:"; - cin >> subString; + string temp = " "; + cout << "Enter the Last Name to search for: "; + cin >> temp; - bool found = false; - int left = 0; - int right = num_records; - int mid = 0; - - while (left <= right && found != true) + string subString{ temp }; + int found = 0; + for (int k = 0; k <= num_records - 1; k++) { - int mid = (left + right / 2); - - if (subString == last[mid]) + if (last[k] == subString) { - cout << "found: " << first[mid] << " " << last[mid] << "\t\tph: " << ph[mid] << "\tDOB: " << bd[mid] << "\n\n\n"; - found = true; - } - else if (subString > last[mid]) - left = mid + 1; - else - right = mid - 1; - + cout << "found: " << first[k] << " " << last[k] << "\t\tph: " << ph[k] << "\tDOB: " << bd[k] << "\n"; + found++; + } } - - if (found != true) - cout << "The account was not found.\n\n"; + if (found == 0) + cout << "Account not found.\n"; + + cout << "\n\n"; DisplayMenu(); - } + void Add() { cout << "Last Name: "; |