diff options
| author | [email protected] <[email protected]> | 2021-11-09 21:27:21 -0800 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2021-11-09 21:27:21 -0800 |
| commit | ec64a30d80f284bf3f1ef2960207f74056dcba28 (patch) | |
| tree | c2ad54bfa4a55658c9dfcc2e46894affb076c895 | |
| parent | Add online IDE url (diff) | |
| download | archived-cst116-lab6-rayyanansari03-ec64a30d80f284bf3f1ef2960207f74056dcba28.tar.xz archived-cst116-lab6-rayyanansari03-ec64a30d80f284bf3f1ef2960207f74056dcba28.zip | |
LAB6 Answers V1
| -rw-r--r-- | CST116F2021-Lab6/CST116F2021-Lab6.cpp | 71 | ||||
| -rw-r--r-- | CST116F2021-Lab6/LAB6Answers.txt | 181 |
2 files changed, 248 insertions, 4 deletions
diff --git a/CST116F2021-Lab6/CST116F2021-Lab6.cpp b/CST116F2021-Lab6/CST116F2021-Lab6.cpp index 466d90f..757b51c 100644 --- a/CST116F2021-Lab6/CST116F2021-Lab6.cpp +++ b/CST116F2021-Lab6/CST116F2021-Lab6.cpp @@ -1,13 +1,76 @@ -// CST116F2021-Lab6.cpp : This file contains the 'main' function. Program execution begins and ends there. +// LAB6Ansari-V2.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> +#include <string> +#include <iomanip> +using namespace std; +void acceptStringInfo(string array1[10][2]); +void acceptNumInfo(int studentNum[10], int moneyForClub[10], string array1[10][2]); +int main() { + + int x = 2; + + + string clubInfo[10][2]; + int studentNum[10]; + int moneyForClub[10]; + + acceptStringInfo(clubInfo); + acceptNumInfo(studentNum, moneyForClub, clubInfo); + + cout << "CLUB : PRESIDENT : STUDENTS : BUDGET" << endl; + for (int z = 0; z < 10; z++) { + + cout << clubInfo[z][0] << " : " << clubInfo[z][1] << " : " << studentNum[z] << " : " << moneyForClub[0] << endl; + + } + -int main() -{ - std::cout << "Hello World!\n"; } +void acceptStringInfo(string array1[10][2]) { + + string club; + string clubPresident; + + + + + for (int i = 0; i < 10; i++) { + + + cout << "Enter club name: "; + getline(cin, club); + cout << endl; + array1[i][0] = club; + + cout << "Enter club president name: "; + getline(cin, clubPresident); + cout << endl; + array1[i][1] = clubPresident; + + + } + +} + + +void acceptNumInfo(int studentNum[10], int moneyForClub[10], string array1[10][2]) { + + int members; + + for (int i = 0; i < 10; i++) { + cout << "How many people are in the club " << array1[i][0] << ": "; + cin >> members; + cout << endl; + studentNum[i] = members; + moneyForClub[i] = members * 75; + } + + + +} // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu diff --git a/CST116F2021-Lab6/LAB6Answers.txt b/CST116F2021-Lab6/LAB6Answers.txt new file mode 100644 index 0000000..8fd8692 --- /dev/null +++ b/CST116F2021-Lab6/LAB6Answers.txt @@ -0,0 +1,181 @@ +11a +10.10 Learn by Doing Exercises +pp 282-283 +10 pts #1 +Submit: code & runs + + + +CODE: + +// LAB6Ansari-V2.cpp : This file contains the 'main' function. Program execution begins and ends there. +// + +#include <iostream> +#include <string> +#include <iomanip> +using namespace std; +void acceptStringInfo(string array1[10][2]); +void acceptNumInfo(int studentNum[10], int moneyForClub[10], string array1[10][2]); +int main() { + + int x = 2; + + + string clubInfo[10][2]; + int studentNum[10]; + int moneyForClub[10]; + + acceptStringInfo(clubInfo); + acceptNumInfo(studentNum, moneyForClub, clubInfo); + + cout << "CLUB : PRESIDENT : STUDENTS : BUDGET" << endl; + for (int z = 0; z < 10; z++) { + + cout << clubInfo[z][0] << " : " << clubInfo[z][1] << " : " << studentNum[z] << " : " << moneyForClub[0] << endl; + + } + + +} + +void acceptStringInfo(string array1[10][2]) { + + string club; + string clubPresident; + + + + + for (int i = 0; i < 10; i++) { + + + cout << "Enter club name: "; + getline(cin, club); + cout << endl; + array1[i][0] = club; + + cout << "Enter club president name: "; + getline(cin, clubPresident); + cout << endl; + array1[i][1] = clubPresident; + + + } + +} + + +void acceptNumInfo(int studentNum[10], int moneyForClub[10], string array1[10][2]) { + + int members; + + for (int i = 0; i < 10; i++) { + cout << "How many people are in the club " << array1[i][0] << ": "; + cin >> members; + cout << endl; + studentNum[i] = members; + moneyForClub[i] = members * 75; + } + + + +} +// 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 + + + +OUTPUT(corrected): + +Enter club name: Computer Systems Society + +Enter club president name: Kim Cares + +Enter club name: Society of Women Engineers + +Enter club president name: Jeanie Queen + +Enter club name: Sigma Tau Gamma + +Enter club president name: Storm Drain + +Enter club name: Trekkies + +Enter club president name: C.Kirk + +Enter club name: Home Brewers + +Enter club president name: Ross Coe + +Enter club name: High Altitude ballooning + +Enter club president name: Justin Time + +Enter club name: Rugby + +Enter club president name: Ryan Johns + +Enter club name: IEEE + +Enter club president name: Marc Bansmere + +Enter club name: International Club + +Enter club president name: Kong Mbonkum + +Enter club name: Dance Club + +Enter club president name: Will Shaver + +How many people are in the club Computer Systems Society: 49 + +How many people are in the club Society of Women Engineers: 51 + +How many people are in the club Sigma Tau Gamma: 241 + +How many people are in the club Trekkies: 230 + +How many people are in the club Home Brewers: 15 + +How many people are in the club High Altitude ballooning: 19 + +How many people are in the club Rugby: 25 + +How many people are in the club IEEE: 36 + +How many people are in the club International Club: 102 + +How many people are in the club Dance Club: 64 + +CLUB : PRESIDENT : STUDENTS : BUDGET +Computer Systems Society : Kim Cares : 49 : 3675 +Society of Women Engineers : Jeanie Queen : 51 : 3675 +Sigma Tau Gamma : Storm Drain : 241 : 3675 +Trekkies : C.Kirk : 230 : 3675 +Home Brewers : Ross Coe : 15 : 3675 +High Altitude ballooning : Justin Time : 19 : 3675 +Rugby : Ryan Johns : 25 : 3675 +IEEE : Marc Bansmere : 36 : 3675 +International Club : Kong Mbonkum : 102 : 3675 +Dance Club : Will Shaver : 64 : 3675 + +C:\Users\ansar\Source\Repos\cst116-lab6-rayyanansari03-V1\Debug\CST116F2021-Lab6.exe (process 16860) 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 . . . + +----------------------------------------------------------------------------------------------------------- + +11b +10.14 Debugging Exercises +pp 289-292 +10 pts #1 +Submit: code & runs |