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 #include #include 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 NOTE: The instruction on the debugging exercise were quite vague so i followed them to the best of my abilities. For example, they ask to modify a value in function 2, but they do not specify whether that value should be altered in the beginning or end of the function. DEBUGGED CODE: #include #include using std::cin; using std::cout; using std::endl; using std::setw; void GetAndDisplayWelcomeInfo(); void FunctionOne(int varX[], int varY[]); void FunctionTwo(int varX[], const int varY[], int varZ[]); void PrintFunction(const int varX[], const int varY[], const int varZ[]); const int SIZE = 10; int main() { int varX[SIZE]; int varY[SIZE]; int varZ[SIZE]; // Notice how we used the const here! // Breakpoint 1 // Put breakpoint on the following line GetAndDisplayWelcomeInfo(); FunctionOne(varX, varY); // Breakpoint 3 // Put breakpoint on the following line FunctionTwo(varX, varY, varZ); varZ[0] = -99; PrintFunction(varX, varY, varZ); return 0; } void GetAndDisplayWelcomeInfo() { char name[2][20]; // First name in row 0, last name in row 1 cout << "Please enter your first name: "; cin >> name[0]; cout << "\nPlease enter your last name: "; cin >> name[1]; // Breakpoint 2 // Put breakpoint on the following line cout << "\n\n\tWelcome " << name[0] << " " << name[1] << "!\n\t Hope all is well \n\n"; } void FunctionOne(int varX[], int varY[]) { for (int x = 0; x < SIZE; x++) // NOTICE '<' NOT <= // Breakpoint 4 // Put breakpoint on the following line varX[x] = x; for (int x = 0; x < 5; x++) varY[x] = x + 100; } void FunctionTwo(int varX[], const int varY[], int varZ[]) { varX[1] = 99; for (int x = 0; x < SIZE; x++) // Notice the const SIZE here varZ[x] = varX[x] + varY[x]; } void PrintFunction(const int varX[20], const int varY[20], const int varZ[20]) { int x; cout << " \t x \t y \t z\n\n"; for (x = 0; x < SIZE; x++) cout << "\t" << setw(3) << varX[x] << "\t " << varY[x] << "\t " << varZ[x] << endl; } OUTPUT: Please enter your first name: Rayyan Please enter your last name: Ansari Welcome Rayyan Ansari! Hope all is well x y z 0 100 -99 99 101 200 2 102 104 3 103 106 4 104 108 5 -858993460 -858993455 6 -858993460 -858993454 7 -858993460 -858993453 8 -858993460 -858993452 9 -858993460 -858993451 C:\Users\ansar\Source\Repos\cst116-lab6-rayyanansari03-V1\Debug\CST116F2021-Lab6.exe (process 2208) 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 . . . --------------------------------------------------------------- 11c 10.15 Programming Exercises pp 292-293 10 pts #1 Submit: code & runs CODE: #include #include #include using namespace std; bool isPalindrome(char str[100]); bool isAlphaStr(char str[100]); int countChar(char str[100], char character); int main() { char str1[100]; char str2[100]; char str3[100]; char repeatedletter; cout << "Enter word that you would like to count repeated character of: "; cin >> str3; cout << endl; cout << "Enter letter you would like to find: "; cin >> repeatedletter; cout << endl; cout << countChar(str3, repeatedletter); cout << endl; cout << "ENter word where you want all alphabet: "; cin >> str2; cout << endl; if (isAlphaStr(str2) == true) { cout << "TRUE"; } else { cout << "FALSE"; } cout << endl; cout << "Enter Palindrome word: "; cin >> str1; if (isPalindrome(str1)) { cout << "true" << endl; } else { cout << "false" << endl; } } bool isPalindrome(char str[100]) { char tempString[100]; bool condition = true; int j = strlen(str) - 1; for (int i = 0; i < strlen(str); i++) { if (str[i] != str[j]) { condition = false; } j--; } return condition; } bool isAlphaStr(char str[100]) { for (int i = 0; i < strlen(str); i++) { if (!isalpha(str[i])) { return false; } } return true; } int countChar(char str[100], char character) { int amount = 0; for (int i = 0; i < strlen(str); i++) { if (str[i] == character) { amount++; } } return amount; } OUTPUT(1): Enter word that you would like to count repeated character of: Hellooooo Enter letter you would like to find: o 5 ENter word where you want all alphabet: hjkdfsn0 FALSE Enter Palindrome word: referr false C:\Users\ansar\Source\Repos\cst116-lab6-rayyanansari03-V1\Debug\CST116F2021-Lab6.exe (process 19652) 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 . . . OUTPUT(2): Enter word that you would like to count repeated character of: hheeellloooom Enter letter you would like to find: m 1 ENter word where you want all alphabet: Hello TRUE Enter Palindrome word: refer true C:\Users\ansar\Source\Repos\cst116-lab6-rayyanansari03-V1\Debug\CST116F2021-Lab6.exe (process 14748) 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 . . .