diff options
Diffstat (limited to 'CST116F2021-Lab6/Functions.cpp')
| -rw-r--r-- | CST116F2021-Lab6/Functions.cpp | 79 |
1 files changed, 77 insertions, 2 deletions
diff --git a/CST116F2021-Lab6/Functions.cpp b/CST116F2021-Lab6/Functions.cpp index c9625b0..57c353e 100644 --- a/CST116F2021-Lab6/Functions.cpp +++ b/CST116F2021-Lab6/Functions.cpp @@ -1,5 +1,7 @@ #include "Header.h" +//11a +//10.10 Learn by Doing Exercises //function getInput definition void getInput(string studentClub, string presidentName, int numberOfStudents, string strClubIndex[10][2], int intClubIndex[], int& repeats) { @@ -17,8 +19,6 @@ void calculateMoney(int intClubIndex[], int intClubMoneyIndex[], int repeats) } } - - //function displayTable definition void displayTable(string strClubIndex[10][2], int intClubIndex[], int intClubMoneyIndex[], int repeats) { @@ -42,4 +42,79 @@ void displayTable(string strClubIndex[10][2], int intClubIndex[], int intClubMon } cout << endl; +} + +//11c +//function getStartup definition +char getStartup(char userString[]) +{ + cout << "Welcome to the super cool string information program!\n" + << endl + << "Please enter your string.\n"; + cin >> userString; + + return '0'; +} +//function isPalindrome definition +int isPalindrome(char userString[]) +{ + //initializations + char forward[30]; + char backward[30]; + int length = 0; + //calculate length of userString + while (userString[length] != '\0') + { + length++; + } + //forward to userString, backward to userString backwards + strcpy_s(forward, 30, userString); + + strcpy_s(backward, 30, userString); + + for (int a = 0, b = (length-1); a < length; a++, b--) + { + backward[a] = forward[b]; + } + //compare forward with backward + if (strcmp(forward, backward) == 0) + { + return 1; + } + else + { + return 0; + } +} + +//function isAlphaStr definition +int isAlphaStr(char userString[]) +{ + for (int a = 0; userString[a] != '\0'; a++) + { + if ((userString[a] < 65 || userString[a] > 90) && (userString[a] < 97 || userString[a] > 122)) + { + return 0; + } + } + return 1; +} + +//function countChar definition +int countChar(char userString[], char& stringCheck) +{ + //initializations + int showCt = 0; + cout << "\nEnter a character to check number of appearances in your string: "; + cin >> stringCheck; + + for (int a = 0; userString[a] != '\0'; a++) + { + if (userString[a] == stringCheck) + { + showCt++; + } + } + + return showCt; }
\ No newline at end of file |