C++ Programm Enter a phone number expressed in letters, output digits. Make program have input another phone number option
I made a program that allows you to enter a phone number in letters, and it outputs the letters expressed in numbers. Here is the prompt.


To make telephone numbers easier to remember, some companies use to show their telephone number. For example, using letters, the telephone number 438-5626 can be shown as Getloan. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 224-5466 can be displayed as Callhome, which uses eight letters. Write a program that prompts the user to enter a telephone number espressed in letters and outputs the corresponding telephone number in idigts. If the user enters more than seven letters, then process only the first seven letters. Also output the - (hyphen) after the third digit. Allow the user to use both uppercase and lowercase letters as well as spaces between words. Moreover, your program should process as many telephone numbers as the user wants.





My code so far....


#include <iostream>


using namespace std;

int main()
{
main:
    char ch1;
    int num1;
    bool repeat;
    char yes;


    cout << "Please enter your telephone number expressed in letters." << endl;
    cin >> ch1;
    cout << "\n";


        for (int i=0; i < 7; i++)
        {

                switch (ch1)
                {

                    case 'A':
                    case 'B':
                    case 'C':
                    case 'a':
                    case 'b':
                    case 'c':
                            cout << "2";
                            cin >> ch1;
                            break;
                    case 'D':
                    case 'E':
                    case 'F':
                    case 'd':
                    case 'e':
                    case 'f':
                            cout << "3";
                            cin >> ch1;
                            break;
                    case 'G':
                    case 'H':
                    case 'I':
                    case 'g':
                    case 'h':
                    case 'i':
                            cout << "4";
                            cin >> ch1;
                            break;
                    case 'J':
                    case 'K':
                    case 'L':
                    case 'j':
                    case 'k':
                    case 'l':
                            cout << "5";
                            cin >> ch1;
                            break;
                    case 'M':
                    case 'N':
                    case 'O':
                    case 'm':
                    case 'n':
                    case 'o':
                            cout << "6";
                            cin >> ch1;
                            break;
                    case 'P':
                    case 'Q':
                    case 'R':
                    case 'S':
                    case 'p':
                    case 'q':
                    case 'r':
                    case 's':
                            cout << "7";
                            cin >> ch1;
                            break;
                    case 'T':
                    case 'U':
                    case 'V':
                    case 't':
                    case 'u':
                    case 'v':
                            cout << "8";
                            cin >> ch1;
                            break;
                    case 'W':
                    case 'X':
                    case 'Y':
                    case 'Z':
                    case 'w':
                    case 'x':
                    case 'y':
                    case 'z':
                            cout << "9";
                            cin >> ch1;
                            break;

                }

        }

            cout << "\n\nWould you like to enter another phone number? Y/N" << endl;
            cin >> yes;
            cout << "\n" << endl;
        if (yes == 'Y')
        {
           goto main;
        }
        else
        {
            goto end;
        }



end:
    return 0;
}

C++ Programm Enter a phone number expressed in letters, output digits. Make program have input another phone number option
===

I made a program that allows you to enter a phone number in letters, and it outputs the letters expressed in numbers. Here is the prompt.


To make telephone numbers easier to remember, some companies use to show their telephone number. For example, using letters, the telephone number 438-5626 can be shown as Getloan. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 224-5466 can be displayed as Callhome, which uses eight letters. Write a program that prompts the user to enter a telephone number espressed in letters and outputs the corresponding telephone number in idigts. If the user enters more than seven letters, then process only the first seven letters. Also output the - (hyphen) after the third digit. Allow the user to use both uppercase and lowercase letters as well as spaces between words. Moreover, your program should process as many telephone numbers as the user wants.





My code so far....


#include <iostream>


using namespace std;

int main()
{
main:
    char ch1;
    int num1;
    bool repeat;
    char yes;


    cout << "Please enter your telephone number expressed in letters." << endl;
    cin >> ch1;
    cout << "\n";


        for (int i=0; i < 7; i++)
        {

                switch (ch1)
                {

                    case 'A':
                    case 'B':
                    case 'C':
                    case 'a':
                    case 'b':
                    case 'c':
                            cout << "2";
                            cin >> ch1;
                            break;
                    case 'D':
                    case 'E':
                    case 'F':
                    case 'd':
                    case 'e':
                    case 'f':
                            cout << "3";
                            cin >> ch1;
                            break;
                    case 'G':
                    case 'H':
                    case 'I':
                    case 'g':
                    case 'h':
                    case 'i':
                            cout << "4";
                            cin >> ch1;
                            break;
                    case 'J':
                    case 'K':
                    case 'L':
                    case 'j':
                    case 'k':
                    case 'l':
                            cout << "5";
                            cin >> ch1;
                            break;
                    case 'M':
                    case 'N':
                    case 'O':
                    case 'm':
                    case 'n':
                    case 'o':
                            cout << "6";
                            cin >> ch1;
                            break;
                    case 'P':
                    case 'Q':
                    case 'R':
                    case 'S':
                    case 'p':
                    case 'q':
                    case 'r':
                    case 's':
                            cout << "7";
                            cin >> ch1;
                            break;
                    case 'T':
                    case 'U':
                    case 'V':
                    case 't':
                    case 'u':
                    case 'v':
                            cout << "8";
                            cin >> ch1;
                            break;
                    case 'W':
                    case 'X':
                    case 'Y':
                    case 'Z':
                    case 'w':
                    case 'x':
                    case 'y':
                    case 'z':
                            cout << "9";
                            cin >> ch1;
                            break;

                }

        }

            cout << "\n\nWould you like to enter another phone number? Y/N" << endl;
            cin >> yes;
            cout << "\n" << endl;
        if (yes == 'Y')
        {
           goto main;
        }
        else
        {
            goto end;
        }



end:
    return 0;
}
