#include <iomanip>
#include <string>
using namespace std;
int ReadDials (char &d1, char &d2, char &d3, char &d4, char &d5, char &d6, char &d7, char &d8); int ToDigit (char &digit); void AcknowledgeCall (char &d1, char &d2, char &d3, char &d4, char &d5, char &d6, char &d7, char &d8);
int main ()
{
// Char variables for the 8 digits of the phone number. char d1, d2, d3, d4, d5, d6, d7, d8;
while (1) { int errorCode = ReadDials(d1, d2, d3, d4, d5, d6, d7, d8);
if (errorCode == -5) break; // Exit the while loop.
switch(errorCode) { case -1: cout << "ERROR - An invalid character was entered" << endl << endl; break;
case -2: cout << "ERROR - Phone number cannot begin with 0" << endl << endl; break;
case -3: cout << "ERROR - Phone number cannot begin with 555" << endl << endl; break;
case -4: cout << "ERROR - Hyphen is not in the correct position" << endl << endl; break;
default: AcknowledgeCall(d1, d2, d3, d4, d5, d6, d7, d8); break; } }
char ch, line[80]; cin.getline(line, 80);
cout << "Press any key to continue..."; cin.get(ch);
return 0;
}
int ReadDials (char &d1, char &d2, char &d3, char &d4, char &d5, char &d6, char &d7, char &d8)
{
cout << "Enter a phone number (Q to quit): "; cin >> d1; // Input the first digit.
if (d1 == 'Q') return -5; // User wants to quit.
// Input the rest of the phone number. cin >>