aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CST116F2021-Lab9/CONSOLE_OUTPUT.txt320
-rw-r--r--CST116F2021-Lab9/CST116F2021-Lab9.cpp48
-rw-r--r--CST116F2021-Lab9/CST116F2021-Lab9.vcxproj9
-rw-r--r--CST116F2021-Lab9/CST116F2021-Lab9.vcxproj.filters1
4 files changed, 352 insertions, 26 deletions
diff --git a/CST116F2021-Lab9/CONSOLE_OUTPUT.txt b/CST116F2021-Lab9/CONSOLE_OUTPUT.txt
new file mode 100644
index 0000000..71654fb
--- /dev/null
+++ b/CST116F2021-Lab9/CONSOLE_OUTPUT.txt
@@ -0,0 +1,320 @@
+This file contains test information for this lab
+
+16a - 11.14 Programming Exercises #2:
+
+Enter name of data file: nope
+Invalid file name
+Enter name of data file: 1114_2_datafile
+The smallest number in the file is: 23
+The largest number in the file is: 2021
+The file contents are:
+23 33 44 120 234 340 501 530 567 2021
+
+C:\Users\jorda\Source\Repos\cst116-lab9-JordanHT-OIT\x64\Debug\CST116F2021-Lab9.exe (process 17276) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .
+
+
+
+16a - 11.14 Programming Exercises #3 (NOTE: Most of the code is shared between #2 and #3):
+
+Enter name of data file: 1114_3_datafile
+
+1) He has a few screws loose. (26 chars)
+2) Barking dogs and screaming toddlers have the unique ability to turn friendly neighbors into cranky enemies. (107 chars)
+3) Mushrooms are a kind of fungus. (31 chars)
+4) In that instant, everything changed. (36 chars)
+5) The toddler's endless tantrum caused the entire plane anxiety. (62 chars)
+6) He decided water-skiing on a frozen lake wasn't a good idea. (60 chars)
+7) You have every right to be angry, but that doesn't give you the right to be mean. (81 chars)
+8) As the years pass by, we all know owners look more and more like their dogs. (76 chars)
+9) Tom didn't sound as if he was in trouble. (41 chars)
+10) The door slammed on the watermelon. (35 chars)
+
+C:\Users\jorda\Source\Repos\cst116-lab9-JordanHT-OIT\x64\Debug\CST116F2021-Lab9.exe (process 7140) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .
+
+
+
+16a - 11.14 Programming Exercises #4:
+
+---[Test 1]---
+
+Personnel manifest explorer MK1
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+1
+Chose search method:
+1) First name and last name
+2) Phone number
+3) Cancel
+1
+Enter the first name (case sensitive): Ray
+Enter the last name (case sensitive): Mccartney
+Match found at index 11:
+Ray Mccartney 425-788-2340 2002-09-03
+
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+7
+Invalid input; enter again: 5
+
+C:\Users\jorda\Source\Repos\cst116-lab9-JordanHT-OIT\x64\Debug\CST116F2021-Lab9.exe (process 15476) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .
+
+
+---[Test 2]---
+
+Personnel manifest explorer MK1
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+1
+Chose search method:
+1) First name and last name
+2) Phone number
+3) Cancel
+2
+Enter the phone number in the format 012-345-6789: 706-820-0848
+Match found at index 12:
+Jannat Kline 706-820-0848 1994-04-01
+
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+3
+Enter 1 if index is known, or 2 to find a person: 1
+Enter index: 12
+Select element to change:
+1) First name
+2) Last name
+3) Phone number
+4) Date of birth
+5) Exit
+3
+Enter the phone number (format: 012-345-6789): 012-345-6789
+Select element to change:
+1) First name
+2) Last name
+3) Phone number
+4) Date of birth
+5) Exit
+1
+Enter the first name: Test
+Select element to change:
+1) First name
+2) Last name
+3) Phone number
+4) Date of birth
+5) Exit
+5
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+1
+Chose search method:
+1) First name and last name
+2) Phone number
+3) Cancel
+1
+Enter the first name (case sensitive): Test
+Enter the last name (case sensitive): Kline
+Match found at index 12:
+Test Kline 012-345-6789 1994-04-01
+
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+5
+
+C:\Users\jorda\Source\Repos\cst116-lab9-JordanHT-OIT\x64\Debug\CST116F2021-Lab9.exe (process 9352) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .
+
+
+---[Test 3]---
+
+Personnel manifest explorer MK1
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+4
+
+First name Last name Phone number Date of birth
+════════════════════════════════════════════════════════════════════════════════════════════════════
+Dionne Arroyo 717-417-5576 1998-02-19
+Benjamin Bullock 870-533-4082 1985-11-09
+Aarav Corbett 586-468-0823 1991-12-14
+Aniyah Davey 620-947-3956 2001-03-08
+Julia Galloway 931-729-9938 1999-06-18
+Jannat Kline 706-820-0848 1994-04-01
+Paisley Mccall 207-865-4000 1970-03-01
+Inigo Massey 253-835-0873 1983-09-28
+Ray Mccartney 425-788-2340 2002-09-03
+Brady Merritt 871-869-7911 1993-09-13
+Odin Obrien 321-783-2687 1983-01-19
+Romany Porter 225-261-7520 1966-05-20
+Aaliyah Pittman 979-258-9565 1980-12-26
+Kaidan Smith 423-842-7402 1987-04-24
+Codey Whyte 615-672-4849 1990-06-10
+
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+3
+Enter 1 if index is known, or 2 to find a person: 2
+Chose search method:
+1) First name and last name
+2) Phone number
+3) Cancel
+1
+Enter the first name (case sensitive): Odin
+Enter the last name (case sensitive): Obrien
+Match found at index 4:Select element to change:
+1) First name
+2) Last name
+3) Phone number
+4) Date of birth
+5) Exit
+2
+Enter the last name: Aleph
+Select element to change:
+1) First name
+2) Last name
+3) Phone number
+4) Date of birth
+5) Exit
+5
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+4
+
+First name Last name Phone number Date of birth
+════════════════════════════════════════════════════════════════════════════════════════════════════
+Odin Aleph 321-783-2687 1983-01-19
+Dionne Arroyo 717-417-5576 1998-02-19
+Benjamin Bullock 870-533-4082 1985-11-09
+Aarav Corbett 586-468-0823 1991-12-14
+Aniyah Davey 620-947-3956 2001-03-08
+Julia Galloway 931-729-9938 1999-06-18
+Jannat Kline 706-820-0848 1994-04-01
+Paisley Mccall 207-865-4000 1970-03-01
+Inigo Massey 253-835-0873 1983-09-28
+Ray Mccartney 425-788-2340 2002-09-03
+Brady Merritt 871-869-7911 1993-09-13
+Romany Porter 225-261-7520 1966-05-20
+Aaliyah Pittman 979-258-9565 1980-12-26
+Kaidan Smith 423-842-7402 1987-04-24
+Codey Whyte 615-672-4849 1990-06-10
+
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+5
+
+C:\Users\jorda\Source\Repos\cst116-lab9-JordanHT-OIT\x64\Debug\CST116F2021-Lab9.exe (process 7504) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .
+
+
+---[Test 4]---
+
+Personnel manifest explorer MK1
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+2
+Enter the first name: Test1
+Enter the last name: Alpha
+Enter the phone number (format: 012-345-6789): 111-111-1111
+Enter the date of birth (format: yyyy-mm-dd): 1111-11-11
+
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+2
+Enter the first name: Test2
+Enter the last name: Zeta
+Enter the phone number (format: 012-345-6789): 222-222-2222
+Enter the date of birth (format: yyyy-mm-dd): 2222-22-22
+
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+4
+
+First name Last name Phone number Date of birth
+════════════════════════════════════════════════════════════════════════════════════════════════════
+Dionne Arroyo 717-417-5576 1998-02-19
+Test1 Alpha 111-111-1111 1111-11-11
+Benjamin Bullock 870-533-4082 1985-11-09
+Aarav Corbett 586-468-0823 1991-12-14
+Aniyah Davey 620-947-3956 2001-03-08
+Julia Galloway 931-729-9938 1999-06-18
+Jannat Kline 706-820-0848 1994-04-01
+Paisley Mccall 207-865-4000 1970-03-01
+Inigo Massey 253-835-0873 1983-09-28
+Ray Mccartney 425-788-2340 2002-09-03
+Brady Merritt 871-869-7911 1993-09-13
+Odin Obrien 321-783-2687 1983-01-19
+Romany Porter 225-261-7520 1966-05-20
+Aaliyah Pittman 979-258-9565 1980-12-26
+Kaidan Smith 423-842-7402 1987-04-24
+Codey Whyte 615-672-4849 1990-06-10
+Test2 Zeta 222-222-2222 2222-22-22
+
+Enter desired operation:
+1) Personnel lookup
+2) Add entry
+3) Edit entry
+4) Display all records
+5) Exit program
+5
+
+C:\Users\jorda\Source\Repos\cst116-lab9-JordanHT-OIT\x64\Debug\CST116F2021-Lab9.exe (process 12408) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . . \ No newline at end of file
diff --git a/CST116F2021-Lab9/CST116F2021-Lab9.cpp b/CST116F2021-Lab9/CST116F2021-Lab9.cpp
index 1372506..f923ec5 100644
--- a/CST116F2021-Lab9/CST116F2021-Lab9.cpp
+++ b/CST116F2021-Lab9/CST116F2021-Lab9.cpp
@@ -24,7 +24,7 @@ int main(void)
int length = 0, data[MV_1];
bool fileValid = false;
- do
+ do //Ask the user for the file name until a valid filename is entered
{
cout << "Enter name of data file: ";
@@ -46,12 +46,12 @@ int main(void)
dataFile.close();
- bubiSort(data, length);
+ bubiSort(data, length); //Sort the array in assending order
cout << "The smallest number in the file is: " << data[0] << "\nThe largest number in the file is: " << data[length - 1] << endl;
cout << "The file contents are: " << endl;
- for (int idx = 0; idx < length; idx++)
+ for (int idx = 0; idx < length; idx++) //Print all of the data
{
cout << data[idx] << " ";
}
@@ -61,6 +61,7 @@ int main(void)
return (0);
}
+//Load an array with data from a filestream
int loadFileData(ifstream& inData, int arr[MV_1])
{
int entries = 0;
@@ -74,6 +75,7 @@ int loadFileData(ifstream& inData, int arr[MV_1])
return (--entries);
}
+//My poor implementation of bubblesort
void bubiSort(int arr[MV_1], int len)
{
int pass = 0, hold = 0;
@@ -106,7 +108,7 @@ int main(void)
bool fileFailed = false;
int lineNumber = 0;
- do
+ do //Ask the user for the file name until a valid filename is entered
{
cout << "Enter name of data file: ";
@@ -123,11 +125,13 @@ int main(void)
} while (fileFailed);
- while (!dataFile.eof())
+ cout << endl;
+
+ while (!dataFile.eof()) //Repeat until EOF
{
getline(dataFile, currentLine);
- cout << 1 + lineNumber++ << ")\t" << currentLine << "\t(" << currentLine.length() << " chars)" << endl;
+ cout << 1 + lineNumber++ << ")\t" << currentLine << "\t(" << currentLine.length() << " chars)" << endl; //Use the .length class to display the number of chars
}
dataFile.close();
@@ -152,7 +156,7 @@ void displayEntry(string[4][MV_3], int);
int main(void)
{
int menuChoice = 0, numEntries = 0, metaData[2][MV_3]{ 0 }, select = 0;
- string fileLoc = "C:\\Users\\jorda\\source\\repos\\cst116-lab9-JordanHT-OIT\\CST116F2021-Lab9\\1114_4_datafile.txt";
+ string fileLoc = "C:\\Users\\jorda\\source\\repos\\cst116-lab9-JordanHT-OIT\\CST116F2021-Lab9\\1114_4_datafile.txt"; //Hardcoded file path because flexibility was not required
string mainData[4][MV_3];
if (!populateDataArray(fileLoc, mainData, numEntries))
@@ -222,7 +226,7 @@ int main(void)
cout << "Invalid input; enter again: ";
}
- if (menuChoice == 1)
+ if (menuChoice == 1) //Direct index imput
{
cout << "Enter index: ";
@@ -231,12 +235,12 @@ int main(void)
cout << "Invalid index";
}
}
- else
+ else //Lookup if the user does not know the index of the entry
{
select = findPerson(mainData, numEntries);
}
- do
+ do //Let the user change any amount of params until they exit
{
cout << "Select element to change:\n1)\tFirst name\n2)\tLast name\n3)\tPhone number\n4)\tDate of birth\n5)\tExit\n";
@@ -278,25 +282,25 @@ int main(void)
}
while (menuChoice != 5);
- menuChoice = -1;
+ menuChoice = -1; //Reset menu value to avoid program exit
break;
- case(4): //Displays all available information
+ case(4): //Displays all available information using metaData as a map
+ cout << left;
+ cout << endl << setw(25) << "First name" << setw(25) << "Last name" << setw(25) << "Phone number" << setw(25) << "Date of birth" << endl;
+ for (int idx = 0; idx < (25 * 4); idx++)
+ {
+ cout << char(205);
+ }
cout << endl;
for (int idx = 0; idx <= numEntries; idx++)
{
- for (int idy = 0; idy <= numEntries; idy++)
- {
- if (metaData[0][idy] == idx)
- {
- displayEntry(mainData, idy);
+ displayEntry(mainData, metaData[0][idx]);
- cout << endl;
- }
- }
+ cout << endl;
}
cout << endl;
@@ -349,7 +353,7 @@ void bubiSortIndex(int map[MV_3], int dataArray[MV_3], int len)
}
}
-//Swaps the dataArray using a map for a specified number of entries (unused)
+//Swaps the dataArray using a map for a specified number of entries (UNUSED)
void swapDataArray(string dataArray[4][MV_3], int meta[MV_3], int &entries)
{
string swapValue[4];
@@ -504,4 +508,4 @@ void displayEntry(string dataArray[4][MV_3], int entry)
{
cout << left;
cout << setw(25) << dataArray[0][entry] << setw(25) << dataArray[1][entry] << setw(25) << dataArray[2][entry] << setw(25) << dataArray[3][entry];
-} \ No newline at end of file
+}
diff --git a/CST116F2021-Lab9/CST116F2021-Lab9.vcxproj b/CST116F2021-Lab9/CST116F2021-Lab9.vcxproj
index a1a93b0..c99789c 100644
--- a/CST116F2021-Lab9/CST116F2021-Lab9.vcxproj
+++ b/CST116F2021-Lab9/CST116F2021-Lab9.vcxproj
@@ -29,26 +29,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@@ -145,6 +145,7 @@
<Text Include="1114_2_datafile.txt" />
<Text Include="1114_3_datafile.txt" />
<Text Include="1114_4_datafile.txt" />
+ <Text Include="CONSOLE_OUTPUT.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/CST116F2021-Lab9/CST116F2021-Lab9.vcxproj.filters b/CST116F2021-Lab9/CST116F2021-Lab9.vcxproj.filters
index 2f9f8f6..8f1e3bc 100644
--- a/CST116F2021-Lab9/CST116F2021-Lab9.vcxproj.filters
+++ b/CST116F2021-Lab9/CST116F2021-Lab9.vcxproj.filters
@@ -23,5 +23,6 @@
<Text Include="1114_2_datafile.txt" />
<Text Include="1114_3_datafile.txt" />
<Text Include="1114_4_datafile.txt" />
+ <Text Include="CONSOLE_OUTPUT.txt" />
</ItemGroup>
</Project> \ No newline at end of file