Help!!!

closed account (LTUMoG1T)
I'm trying to figure out what I did wrong with this while loop. I want the program to run until the user inputs "$."

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
 char letter;
    
    cout << "Enter a letter to see the corresponding number on the telephone" << endl; 
    cin >> letter;
    while (letter != '$') {
        switch (letter) {
            case 'A':
            case 'B':
            case 'C':
                cout << "The number is 2 on the telephone.";
                cout << endl;
                break;
            case 'D':
            case 'E':
            case 'F':
                cout << "The number is 3 on the telephone.";
                cout << endl;
                break;
            case 'G':
            case 'H':
            case 'I':
                cout << "The number is 4 on the telephone.";
                cout << endl;
                
                break;
            case 'J':
            case 'K':
            case 'L':
                cout << "The number is 5 on the telephone.";
                cout << endl;
                
                break;
                
            case 'M':
            case 'N':
            case 'O':
                cout << "The number is 6 on the telephone.";
                cout << endl;
                
                break;
                
            case 'P':
            case 'R':
            case 'S':
                cout << "This number is 7 on the telephone.";
                cout << endl;
                
                break;
                
            case 'T':
            case 'U':
            case 'V':
                cout << "The number is 8 on the telephone.";
                cout << endl;
                
                break;
                
            case 'W':
            case 'X':
            case 'Y':
                cout << "The number is 9 on the telephone.";
                cout << endl;
                
                break;
                
            case 'Q':
            default:
                cout << endl;
                cout << "Invalid entry" << endl;
        }
        cin >> letter;
    }
And what is it doing? And since you're dealing with a char input don't forget about the end of line character that will be left in the input buffer.

works for me...
but you have set it up so only Uppercase letters work

let me be mr obvious and ask...did you put this in your main function :? lol
Last edited on
What is wrong with your loop? What is your issue because it works for me...
Topic archived. No new replies allowed.