Switch Statement Counting Different Characters

Hello, I am still fairly new to C++ and I have been having a lot of trouble with a certain code. I am supposed to be able to count the total characters in a string, along with the letters, numbers, and symbols separately using switch statements. However, I can only seem to get the total operating, and nothing else. Is there any way to help me? Here is the code:

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
  #include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main ()
{
    string s;
    int i;
    int letters;
    int numbers;
    int symbols;
    int total;

    cout << "Please enter a continuous string of characters with no spaces." << endl;
    cout << "(example: abcd45768^&*^)" << endl;
    cout << endl;
    cout << "Enter your string: " << endl;
    cin >> s;

    letters = 0;
    numbers = 0;
    symbols = 0;
    i = 0;

    switch(s[i])
    {
        case '1'; case '2'; case '3'; case '4'; case '5'; case '6'; case '7'; case '9';
            numbers += 1;

        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q':
        case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H':
        case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Z':
            letters += 1;
    default:
        symbols += 1;
    }
            i++;

    total = (letters + numbers + symbols);

    cout << "Your string has " << s.length() << " total characters." << std::endl;
    cout << letters << " letters" << std::endl;
    cout << numbers << " numerical characters" << std::endl;
    cout << symbols << " other characters" << std:: endl;


}


The results I get from the console are akin to this:

Please enter a continuous string of characters with no spaces.
(example: abcd45768^&*^)

Enter your string:
FE:HELKadsefjkl438759439(*%^$#(#
Your string has 32 total characters.
1 letters
0 numerical characters
1 other characters

Process returned 0 (0x0) execution time : 9.938 s
Press any key to continue.
You need to use a loop. At the moment you are only counting the first letter.
closed account (48T7M4Gy)
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
#include <iostream>
#include <string>

using namespace std;

int main ()
{
    string s;
    int i;
    int letters;
    int numbers;
    int symbols;
    int total;

    cout << "Please enter a continuous string of characters with no spaces." << endl;
    cout << "(example: abcd45768^&*^)" << endl;
    cout << endl;
    cout << "Enter your string: " << endl;
    cin >> s;

    letters = 0;
    numbers = 0;
    symbols = 0;
    i = 0;
while(s[i] != '\0')
{
    switch(s[i])
    {
        case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '9': case '0':
            numbers += 1;
            break;

        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q':
        case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H':
        case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Z':
            letters += 1;
            break;
    default:
        symbols += 1;
    }
            i++;
}

    total = (letters + numbers + symbols);

    cout << "Your string has " << total << " total characters." << std::endl;
    cout << letters << " letters" << std::endl;
    cout << numbers << " numerical characters" << std::endl;
    cout << symbols << " other characters" << std:: endl;


}
Thank you all for your speedy replies, I have now got a working program! I will be sure to keep function isalpha and isdigit in my references. Thank you all for your help again, I think understand better now how to use these switch statements to my advantage!
Topic archived. No new replies allowed.