aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Ten Eyck <[email protected]>2021-11-11 00:34:03 -0800
committerJoseph Ten Eyck <[email protected]>2021-11-11 00:34:03 -0800
commitea266a4b6b0a07ff4e0842a9653b1634ac95f8ab (patch)
tree44b9d43b836373e6a4cafa7de191aa44a5515d8a
parentLast problem is giving me trouble. I am pushing what I have before midnight s... (diff)
downloadcst116-lab6-josephteneyck-master.tar.xz
cst116-lab6-josephteneyck-master.zip
Figured out what was giving me trouble! This is the completed assignment.HEADmaster
-rw-r--r--CST116F2021-Lab6/CST116F2021-Lab6 - Joseph Ten Eyck.cpp26
-rw-r--r--CST116F2021-Lab6/Functions.cpp281
-rw-r--r--CST116F2021-Lab6/Header.h33
-rw-r--r--RUNS.txt143
4 files changed, 336 insertions, 147 deletions
diff --git a/CST116F2021-Lab6/CST116F2021-Lab6 - Joseph Ten Eyck.cpp b/CST116F2021-Lab6/CST116F2021-Lab6 - Joseph Ten Eyck.cpp
index 06a47cf..d518b6e 100644
--- a/CST116F2021-Lab6/CST116F2021-Lab6 - Joseph Ten Eyck.cpp
+++ b/CST116F2021-Lab6/CST116F2021-Lab6 - Joseph Ten Eyck.cpp
@@ -184,16 +184,16 @@
//====================================================================
-#include "Header.h"
-
-int main()
-{
- int menu_choice = 0;
-
- do
- {
- displayMenu(menu_choice); //Displays menu choices and takes in user choice
-
- processMenuChoice(menu_choice); //Process menu choice, calls relevant function
- } while (menu_choice != 4);
-} \ No newline at end of file
+//#include "Header.h"
+//
+//int main()
+//{
+// int menu_choice = 0;
+//
+// do
+// {
+// displayMenu(menu_choice); //Displays menu choices and takes in user choice
+//
+// processMenuChoice(menu_choice); //Process menu choice, calls relevant function
+// } while (menu_choice != 4);
+//} \ No newline at end of file
diff --git a/CST116F2021-Lab6/Functions.cpp b/CST116F2021-Lab6/Functions.cpp
index b6683ec..5c80b3f 100644
--- a/CST116F2021-Lab6/Functions.cpp
+++ b/CST116F2021-Lab6/Functions.cpp
@@ -43,121 +43,166 @@
// CODE FOR PROBLEM #1 ON PAGE 292 (PROGRAMMING EXERCISES) IS BELOW
//====================================================================
-#include "Header.h"
-
-void displayMenu(int& menu_choice) //Displays menu choices and takes in user choice
-{
- do
- {
- cout << "\n\t\t==============================";
- cout << "\n\t\t What would you like to do?";
- cout << "\n\t\t==============================";
-
- cout << "\n\n\t1) Test if a string is a palindrome";
- cout << "\n\t2) Test if a string is all alphabetic characters";
- cout << "\n\t3) Count the number of times a specific character appears in a string";
- cout << "\n\t4) Exit";
-
- cout << "\n\n\t\tMenu choice #: ";
- cin >> menu_choice;
-
- if (menu_choice < 1 || menu_choice > 4)
- {
- cout << "\n\nError: Invalid menu choice\n";
- }
- } while (menu_choice < 1 || menu_choice > 4);
-}
-
-void processMenuChoice(int menu_choice) //Process menu choice, calls relevant function
-{
- switch (menu_choice) {
-
- case 1:
- {
- isPalindrome();
- break;
- }
-
- case 2:
- {
- isAlphaStr();
- break;
- }
-
- case 3:
- {
- countChar();
- break;
- }
-
- case 4:
- {
- cout << "\n\t\t\t~ Goodbye! ~\n\n";
- break;
- }
- }
-
-}
-
-void isPalindrome() //Checks whether or not a user input string is a palindrome
-{
- char string1[41];
- char stringR[41];
- int same = 2;
-
- cout << "\n\t\t---------------------------------------------------------";
- cout << "\n\t\t Enter a string (up to 40 characters, spaces are okay)";
- cout << "\n\t\t---------------------------------------------------------";
-
- cin.ignore(numeric_limits<streamsize>::max(), '\n'); //****Ignores everything in the input buffer up to this point
-
- cout << "\n\tEnter string: ";
- cin.getline(string1, 41);
-
- strcpy_s(stringR, string1);
-
- _strrev(stringR);
-
-
- same = strcmp(string1, stringR);
-
- if (same == 0)
- {
- cout << "\n\tThe string is a palindrome!\n";
- }
- else if (same == 1)
- {
- cout << "\n\tThe string is not a palindrome.\n";
- }
-}
-
-void isAlphaStr() //Checks to see if a user input string contains all alphabetic characters or not, displays result
-{
- char string2[31];
- int strLength = 0;
- int flag = 0;
-
- cout << "\n\t\t---------------------------------------------------";
- cout << "\n\t\t Enter a string (up to 30 characters, no spaces)";
- cout << "\n\t\t---------------------------------------------------";
-
- cin.ignore(numeric_limits<streamsize>::max(), '\n'); //****Ignores everything in the input buffer up to this point
-
- cout << "\n\tEnter string: ";
- cin.getline(string2, 31);
-
- strLength = strlen(string2);
-
- for (int i = 0; i < strlength - 1; i++)
- {
- if (isalpha(string2))
- {
-
- }
- }
-}
-
-void countChar() //Takes in a user input string and a character, counts the frequency of that character within the string, displays result
-{
-
-} \ No newline at end of file
+//#include "Header.h"
+//
+//void displayMenu(int& menu_choice) //Displays menu choices and takes in user choice
+//{
+// do
+// {
+// cout << "\n\t\t==============================";
+// cout << "\n\t\t What would you like to do?";
+// cout << "\n\t\t==============================";
+//
+// cout << "\n\n\t1) Test if a string is a palindrome";
+// cout << "\n\t2) Test if a string is all alphabetic characters";
+// cout << "\n\t3) Count the number of times a specific character appears in a string";
+// cout << "\n\t4) Exit";
+//
+// cout << "\n\n\t\tMenu choice #: ";
+// cin >> menu_choice;
+//
+// if (menu_choice < 1 || menu_choice > 4)
+// {
+// cout << "\n\nError: Invalid menu choice\n";
+// }
+// } while (menu_choice < 1 || menu_choice > 4);
+//}
+//
+//void processMenuChoice(int menu_choice) //Process menu choice, calls relevant function
+//{
+// switch (menu_choice) {
+//
+// case 1:
+// {
+// isPalindrome();
+// break;
+// }
+//
+// case 2:
+// {
+// isAlphaStr();
+// break;
+// }
+//
+// case 3:
+// {
+// countChar();
+// break;
+// }
+//
+// case 4:
+// {
+// cout << "\n\t\t\t~ Goodbye! ~\n\n";
+// break;
+// }
+// }
+//
+//}
+//
+//void isPalindrome() //Checks whether or not a user input string is a palindrome
+//{
+// char string1[41];
+// char stringR[41];
+// int same = 2;
+//
+// cout << "\n\t\t---------------------------------------------------------";
+// cout << "\n\t\t Enter a string (up to 40 characters, spaces are okay)";
+// cout << "\n\t\t---------------------------------------------------------";
+//
+// cin.ignore(numeric_limits<streamsize>::max(), '\n'); //****Ignores everything in the input buffer up to this point
+//
+// cout << "\n\tEnter string: ";
+// cin.getline(string1, 41);
+//
+// strcpy_s(stringR, string1);
+//
+// _strrev(stringR);
+//
+//
+// same = strcmp(string1, stringR);
+//
+// if (same == 0)
+// {
+// cout << "\n\tThe string is a palindrome!\n";
+// }
+// else if (same == 1)
+// {
+// cout << "\n\tThe string is not a palindrome.\n";
+// }
+//}
+//
+//void isAlphaStr() //Checks to see if a user input string contains all alphabetic characters or not, displays result
+//{
+// char string2[31];
+// int strLength = 0;
+// int flag = 0;
+//
+// cout << "\n\t\t---------------------------------------------------";
+// cout << "\n\t\t Enter a string (up to 30 characters, no spaces)";
+// cout << "\n\t\t---------------------------------------------------";
+//
+// cin.ignore(numeric_limits<streamsize>::max(), '\n'); //****Ignores everything in the input buffer up to this point
+//
+// cout << "\n\tEnter string: ";
+// cin.getline(string2, 31);
+//
+// strLength = strlen(string2);
+//
+// for (int i = 0; i < strLength; i++)
+// {
+// if (isalpha(string2[i]))
+// {
+//
+// }
+// else
+// {
+// flag++;
+// }
+// }
+//
+// if (flag != 0)
+// {
+// cout << "\n\t~ Not all characters are alphabetic. ~\n";
+// }
+// else
+// {
+// cout << "\n\t~ All characters are alphabetic! ~\n";
+// }
+//}
+//
+//void countChar() //Takes in a user input string and a character, counts the frequency of that character within the string, displays result
+//{
+// char string3[41];
+// char check = '0';
+// int strLength = 0;
+// int frequency = 0;
+//
+// cout << "\n\t\t---------------------------------------------------------";
+// cout << "\n\t\t Enter a string (up to 40 characters, spaces are okay)";
+// cout << "\n\t\t---------------------------------------------------------";
+//
+// cin.ignore(numeric_limits<streamsize>::max(), '\n'); //****Ignores everything in the input buffer up to this point
+//
+// cout << "\n\tEnter string: ";
+// cin.getline(string3, 41);
+//
+// strLength = strlen(string3);
+//
+// cout << "\n\t\t-----------------------------------------------";
+// cout << "\n\t\t Enter a character to count the frequency of";
+// cout << "\n\t\t-----------------------------------------------";
+//
+// cout << "\n\tCharacter: ";
+// cin >> check;
+//
+// for (int i = 0; i < strLength; i++)
+// {
+// if (string3[i] == check)
+// {
+// frequency++;
+// }
+//
+// }
+//
+// cout << "\n\t~ The frequency of the character '" << check << "' is " << frequency << ". ~\n" << endl;
+//} \ No newline at end of file
diff --git a/CST116F2021-Lab6/Header.h b/CST116F2021-Lab6/Header.h
index 3eb3323..d36036c 100644
--- a/CST116F2021-Lab6/Header.h
+++ b/CST116F2021-Lab6/Header.h
@@ -17,19 +17,20 @@
// CODE FOR PROBLEM #1 ON PAGE 292 (PROGRAMMING EXERCISES) IS BELOW
//====================================================================
-#include <iostream>
-#include <string>
-#include <cstring>
-#include <iomanip>
-
-using namespace std;
-
-void displayMenu(int&); //Displays menu choices and takes in user choice
-
-void processMenuChoice(int); //Process menu choice, calls relevant function
-
-void isPalindrome(); //Checks whether or not a user input string is a palindrome and displays result
-
-void isAlphaStr(); //Checks to see if a user input string contains all alphabetic characters or not, displays result
-
-void countChar(); //Takes in a user input string and a character, counts the frequency of that character within the string, displays result \ No newline at end of file
+//#include <iostream>
+//#include <string>
+//#include <cstring>
+//#include <iomanip>
+//#include <cctype>
+//
+//using namespace std;
+//
+//void displayMenu(int&); //Displays menu choices and takes in user choice
+//
+//void processMenuChoice(int); //Process menu choice, calls relevant function
+//
+//void isPalindrome(); //Checks whether or not a user input string is a palindrome and displays result
+//
+//void isAlphaStr(); //Checks to see if a user input string contains all alphabetic characters or not, displays result
+//
+//void countChar(); //Takes in a user input string and a character, counts the frequency of that character within the string, displays result \ No newline at end of file
diff --git a/RUNS.txt b/RUNS.txt
index 07afccb..780d6cc 100644
--- a/RUNS.txt
+++ b/RUNS.txt
@@ -253,3 +253,146 @@ Press any key to close this window . . .
+
+ ==============================
+ What would you like to do?
+ ==============================
+
+ 1) Test if a string is a palindrome
+ 2) Test if a string is all alphabetic characters
+ 3) Count the number of times a specific character appears in a string
+ 4) Exit
+
+ Menu choice #: 2
+
+ ---------------------------------------------------
+ Enter a string (up to 30 characters, no spaces)
+ ---------------------------------------------------
+ Enter string: hello
+
+ All characters are alphabetic!
+
+ ==============================
+ What would you like to do?
+ ==============================
+
+ 1) Test if a string is a palindrome
+ 2) Test if a string is all alphabetic characters
+ 3) Count the number of times a specific character appears in a string
+ 4) Exit
+
+ Menu choice #: 2
+
+ ---------------------------------------------------
+ Enter a string (up to 30 characters, no spaces)
+ ---------------------------------------------------
+ Enter string: again?
+
+ Not all characters are alphabetic.
+
+ ==============================
+ What would you like to do?
+ ==============================
+
+ 1) Test if a string is a palindrome
+ 2) Test if a string is all alphabetic characters
+ 3) Count the number of times a specific character appears in a string
+ 4) Exit
+
+ Menu choice #:
+
+
+
+
+
+
+
+ ==============================
+ What would you like to do?
+ ==============================
+
+ 1) Test if a string is a palindrome
+ 2) Test if a string is all alphabetic characters
+ 3) Count the number of times a specific character appears in a string
+ 4) Exit
+
+ Menu choice #: 3
+
+ ---------------------------------------------------------
+ Enter a string (up to 40 characters, spaces are okay)
+ ---------------------------------------------------------
+ Enter string: hello kile!
+
+ -----------------------------------------------
+ Enter a character to count the frequency of
+ -----------------------------------------------
+ Character: l
+
+ ~ The frequency of the character 'l' is 3. ~
+
+
+ ==============================
+ What would you like to do?
+ ==============================
+
+ 1) Test if a string is a palindrome
+ 2) Test if a string is all alphabetic characters
+ 3) Count the number of times a specific character appears in a string
+ 4) Exit
+
+ Menu choice #: 3
+
+ ---------------------------------------------------------
+ Enter a string (up to 40 characters, spaces are okay)
+ ---------------------------------------------------------
+ Enter string: dad dude
+
+ -----------------------------------------------
+ Enter a character to count the frequency of
+ -----------------------------------------------
+ Character: d
+
+ ~ The frequency of the character 'd' is 4. ~
+
+
+ ==============================
+ What would you like to do?
+ ==============================
+
+ 1) Test if a string is a palindrome
+ 2) Test if a string is all alphabetic characters
+ 3) Count the number of times a specific character appears in a string
+ 4) Exit
+
+ Menu choice #: 3
+
+ ---------------------------------------------------------
+ Enter a string (up to 40 characters, spaces are okay)
+ ---------------------------------------------------------
+ Enter string: hello planet!
+
+ -----------------------------------------------
+ Enter a character to count the frequency of
+ -----------------------------------------------
+ Character: x
+
+ ~ The frequency of the character 'x' is 0. ~
+
+
+ ==============================
+ What would you like to do?
+ ==============================
+
+ 1) Test if a string is a palindrome
+ 2) Test if a string is all alphabetic characters
+ 3) Count the number of times a specific character appears in a string
+ 4) Exit
+
+ Menu choice #: 4
+
+ ~ Goodbye! ~
+
+
+C:\Users\eclip\Source\Repos\cst116-lab6-JosephTenEyck\Debug\CST116F2021-Lab6.exe (process 10696) 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 . . .