aboutsummaryrefslogtreecommitdiff
path: root/mod11c.cpp
blob: be91372b8429557d59014783e8679a614b5ae5bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Tyler Taormina
// CST 116
// Module 11c
//

#include <iostream>
#include <iomanip>

using namespace std;

void isPalindrome(string);
void isAlpha(string);
void countChar(string);
void getData(string&);
void DisplayMenu(int&);
void processChoice(int, string);

int main() {
    string user_string;
    int user_choice;

    cout << "=================================================================" << endl;
    cout << "PROGRAM RUNNING.." << endl;
    cout << "=================================================================" << endl;
    cout << endl;
    getData(user_string);
    DisplayMenu(user_choice);
    processChoice(user_choice, user_string);

    return 0;

}

void getData(string& usr_data)
{
    cout << "Lets take a look at how to 'check' a string..." << endl;
    cout << "Please enter a word: ";
    cin >> usr_data;
}


void DisplayMenu(int& user_choice)
{
    cout << "Choose what you would like to check for in the string" << endl;
    cout << "that you entered..." << endl;
    cout << "=================================================================" << endl;
    //displays the menu of functions for the user to choose from

    cout << "1) Check for palindrome.\n";
    cout << "2) Check for all alpha.\n";
    cout << "3) Count the number of times a letter is in a word.\n";
    cout << "4) Exit Program.\n\n";
    cout << "Enter: ";
    cin >> user_choice;
    if (user_choice > 4 || user_choice< 1) {
        cout << "Invalid Entry. Please enter a number from the options list provided.\n\n\n\n" << endl;
        DisplayMenu(user_choice);
    }
} 



void ProcessMenuChoice (int menu_choice, string user_str) {
    // Uses the user menu choice input to determine which function to call.
    // Also controls the ending or restarting of program.
    int program_rerun = 0;
    switch(menu_choice){
        case 1: 
            isPalindrome(user_str);
            break;
        
        case 2: 
            isAlpha(user_str);
            break;

        case 3:
            countChar(user_str);
            break;

        case 4:
            cout << "Are you sure you want to exit? Enter 1 to end program." << endl;
            break;

        default:
            break;
    }
    cout << "Press 1 and enter to rerun program. Enter any other number to close program: ";
    cin >> program_rerun;

    if (program_rerun == 1)
        main();
    else {
    cout << "================================================================" << endl;
    cout <<  "Program Closing..." << endl;
    cout << "================================================================\n\n\n" << endl;
    }
}



void isPalindrome (string usr_data) 
{
    cout << "is palindrome" << endl;
}


void isAlpha (string usr_data) 
{
    cout << " alphabet check" << endl;
}


void countChar (string usr_data)
{
    cout << "Counting characters.." << endl;
}