aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CST116F2021-Lab6/CST116F2021-Lab6.cpp56
-rw-r--r--CST116F2021-Lab6/CST116F2021-Lab6.vcxproj4
-rw-r--r--CST116F2021-Lab6/CST116F2021-Lab6.vcxproj.filters8
-rw-r--r--CST116F2021-Lab6/Functions.cpp45
-rw-r--r--CST116F2021-Lab6/Header.h13
5 files changed, 109 insertions, 17 deletions
diff --git a/CST116F2021-Lab6/CST116F2021-Lab6.cpp b/CST116F2021-Lab6/CST116F2021-Lab6.cpp
index 466d90f..f2bb35a 100644
--- a/CST116F2021-Lab6/CST116F2021-Lab6.cpp
+++ b/CST116F2021-Lab6/CST116F2021-Lab6.cpp
@@ -1,20 +1,42 @@
-// CST116F2021-Lab6.cpp : This file contains the 'main' function. Program execution begins and ends there.
-//
-
-#include <iostream>
+#include "Header.h"
int main()
{
- std::cout << "Hello World!\n";
-}
-
-// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
-// Debug program: F5 or Debug > Start Debugging menu
-
-// Tips for Getting Started:
-// 1. Use the Solution Explorer window to add/manage files
-// 2. Use the Team Explorer window to connect to source control
-// 3. Use the Output window to see build output and other messages
-// 4. Use the Error List window to view errors
-// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
-// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
+ //definitions
+ string clubName, president;
+ int numberStudents, repeats = 0;
+ string strClubIndex[10][2];
+ int intClubIndex[10], intClubMoneyIndex[10];
+ //greeting
+ cout << "--Student Club Organizer--\n" << endl;
+ //input
+ while (repeats <= 9)
+ {
+ if (repeats == 9)
+ {
+ cout << "\nThis is your final club input slot. The program will end after this input.\n";
+ }
+ cout << "To stop adding club info, enter \"end\".\n"
+ << "Name of club: \n";
+ getline(cin, clubName);
+ if (clubName == "end")
+ {
+ break;
+ }
+ cout << "\nName of club president: \n";
+ getline(cin, president);
+ cout << "\nNumber of students in club: \n";
+ cin >> numberStudents;
+ //fill available slot
+ getInput(clubName, president, numberStudents, strClubIndex, intClubIndex, repeats);
+ cin.ignore();
+ cout << endl;
+ repeats++;
+ }
+ //calculate club money
+ calculateMoney(intClubIndex, intClubMoneyIndex, repeats);
+ //output
+ displayTable(strClubIndex, intClubIndex, intClubMoneyIndex, repeats);
+ //exit
+ return 0;
+} \ No newline at end of file
diff --git a/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj b/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj
index 756680b..f4b7798 100644
--- a/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj
+++ b/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj
@@ -140,6 +140,10 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="CST116F2021-Lab6.cpp" />
+ <ClCompile Include="Functions.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Header.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj.filters b/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj.filters
index afbfcf4..8171ab3 100644
--- a/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj.filters
+++ b/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj.filters
@@ -18,5 +18,13 @@
<ClCompile Include="CST116F2021-Lab6.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="Functions.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Header.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/CST116F2021-Lab6/Functions.cpp b/CST116F2021-Lab6/Functions.cpp
new file mode 100644
index 0000000..c9625b0
--- /dev/null
+++ b/CST116F2021-Lab6/Functions.cpp
@@ -0,0 +1,45 @@
+#include "Header.h"
+
+//function getInput definition
+void getInput(string studentClub, string presidentName, int numberOfStudents, string strClubIndex[10][2], int intClubIndex[], int& repeats)
+{
+ strClubIndex[repeats][0] = studentClub;
+ strClubIndex[repeats][1] = presidentName;
+ intClubIndex[repeats] = numberOfStudents;
+}
+
+//function calculateMoney definition
+void calculateMoney(int intClubIndex[], int intClubMoneyIndex[], int repeats)
+{
+ for (int clubCount = 0; clubCount <= repeats; clubCount++)
+ {
+ intClubMoneyIndex[clubCount] = intClubIndex[clubCount] * 75;
+ }
+}
+
+
+
+//function displayTable definition
+void displayTable(string strClubIndex[10][2], int intClubIndex[], int intClubMoneyIndex[], int repeats)
+{
+
+ cout << "\n--Club Table--\n" << endl;
+ cout << "Student Club";
+ cout.width(10);
+ cout << "President";
+ cout.width(10);
+ cout << "Number of Students";
+ cout.width(10);
+ cout << endl;
+
+ for (int i = 0; i < repeats; i++)
+ {
+ cout << "| Club name: " << strClubIndex[i][0]
+ << " | Club President: " << strClubIndex[i][1]
+ << " | Number of Students: " << intClubIndex[i]
+ << " | Club Money: " << intClubMoneyIndex[i] << " |"
+ << endl;
+ }
+
+ cout << endl;
+} \ No newline at end of file
diff --git a/CST116F2021-Lab6/Header.h b/CST116F2021-Lab6/Header.h
new file mode 100644
index 0000000..224d2e4
--- /dev/null
+++ b/CST116F2021-Lab6/Header.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <iostream>
+#include <string>
+using namespace std;
+
+//function getInput prototype
+void getInput(string studentClub, string presidentName, int numberOfStudents, string strClubIndex[10][2], int intClubIndex[], int& repeats);
+//function calculateMoney prototype
+void calculateMoney(int intClubIndex[], int intClubMoneyIndex[], int repeats);
+
+//function displayTable prototype
+void displayTable(string strClubIndex[10][2], int intClubIndex[], int intClubMoneyIndex[], int repeats); \ No newline at end of file