I am doing a program for homework and am having trouble asking the user if they want to enter another number. Here is the question:
make telephone numbers easier to remember, some companies use letters to show their telephone number. For example, some companies use letters to show their telephone number. For example, using letters, the telephone number 438 – 5626 can be shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 225 – 5466 can be displayed as CALL HOME, which use eight letters. Write a program that prompts the user to enter a telephone number expressed in letters and outputs the corresponding telephone number in digits. 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.
I have an if (digit == 0) at the end. This is my attempt at asking the user to enter another number but it ends up messing with the whole program. Everything worked fine until I enter that piece of code.
Any suggestions?
#include <iostream>
using namespace std;
int main()
{
char letter, anotherNumber = 0;
int digit, num, counter;
cout << "Program to convert telepone expressed in letters to numbers "
<< endl;
cout << "Enter a phone number in uppercase or lower case letters: ";
cin >> letter;
cout << endl;
counter = 0;
while (counter < 7)
{
if (counter == 3)
cout << "-";
if (65 <= letter && letter < 91)
{
num = static_cast<int>(letter)
- static_cast<int>('A');