From 2848fb6be02d8235583dce48b8b202aef73ce033 Mon Sep 17 00:00:00 2001 From: BensProgramma <91996773+BensProgramma@users.noreply.github.com> Date: Tue, 7 Dec 2021 15:10:17 -0800 Subject: Final Update --- CST116F2021-Lab9/CST116F2021-Lab9_Schroeder.cpp | 82 ++++++++++++------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/CST116F2021-Lab9/CST116F2021-Lab9_Schroeder.cpp b/CST116F2021-Lab9/CST116F2021-Lab9_Schroeder.cpp index 6aac72e..0ac4b01 100644 --- a/CST116F2021-Lab9/CST116F2021-Lab9_Schroeder.cpp +++ b/CST116F2021-Lab9/CST116F2021-Lab9_Schroeder.cpp @@ -86,6 +86,7 @@ int main() + // /// 11.14 Programming Exercises pp 337 - 338 #4 /////////////////////////////////////////////////////////////////////// #include #include @@ -123,6 +124,7 @@ int main() >> bd[num_records]; num_records++; } + fin.close(); DisplayMenu(); @@ -144,36 +146,35 @@ void DisplayMenu() switch (menuChoice) { - case 1: - { - Find(); - break; - } - case 2: - { - Add(); - break; - } - case 3: - { - Edit(); - break; - } - case 4: - { - Display(); - break; - } - case 5: - { - Update(); - cout << "\tThank you, Goodbye!"; - break; - } + case 1: + { + Find(); + break; + } + case 2: + { + Add(); + break; + } + case 3: + { + Edit(); + break; + } + case 4: + { + Display(); + break; + } + case 5: + { + Update(); + cout << "\tThank you, Goodbye!"; + break; + } } } - void Find() { string temp = " "; @@ -199,8 +200,6 @@ void Find() } - - void Add() { cout << "Last Name: "; @@ -212,17 +211,16 @@ void Add() cout << "Date Of Birth: "; cin >> bd[num_records]; num_records++; - + cout << "\n\n"; DisplayMenu(); - } void Edit() { Sort(); - cout << "\nAll of the current records:\n"; + cout << "\nAll of the current records:\n"; for (int k = 0; k <= num_records - 1; k++) { cout << k + 1 << ".\t" << first[k] << " " << last[k] << "\t\tph: " << ph[k] << "\tDOB: " << bd[k] << "\n"; @@ -245,13 +243,13 @@ void Edit() void Display() -{ +{ Sort(); - + cout << "\nAll of the current records:\n"; //sorted alphabetically by last name - for (int k = 0; k <= num_records - 1; k++) + for (int k=0;k<=num_records-1;k++) { - cout << k + 1 << ".\t" << first[k] << " " << last[k] << "\t\tph: " << ph[k] << "\tDOB: " << bd[k] << "\n"; + cout << k + 1 << ".\t" << first[k]<<" "<< last[k]<<"\t\tph: "< (last[i + 1])) { tmp1 = last[i]; tmp2 = first[i]; tmp3 = ph[i]; tmp4 = bd[i]; @@ -291,12 +290,11 @@ void Update() Sort(); fout.open("INFO.txt"); - for (int i = 0; i <= num_records - 1; i++) - fout << first[i] << " " << last[i] << " " << ph[i] << " " << bd[i] << endl; - //fout << first[i] << "\n" << last[i] << "\n" << ph[i] << "\n" << bd[i] << "\n"; - + for (int i = 0; i <=num_records-2; i++) + fout << first[i] << " " << last[i] << " " << ph[i] <<" "<< bd[i] << endl; + //fout << first[i] << "\n" << last[i] << "\n" << ph[i] << "\n" << bd[i] << "\n"; + fout << first[num_records-1] << " " << last[num_records - 1] << " " << ph[num_records - 1] << " " << bd[num_records - 1]; fout.close(); - } -- cgit v1.2.3