int main()
{
int d1 =-6, d2 =-6, d3 = -6, d4 =-6, d5 = -6, d6 = -6, d7 = -6, d8 = -6;
int result = -6;
while (result != -5)
{
result = readDials(d1, d2, d3, d4, d5, d6, d7, d8);
switch(result)
{
case -1: cout << "ERROR - An invalid character was entered" << endl; break;
case -2: cout << "ERROR - Phone number cannot begin with 0" << endl; break;
case -3: cout << "ERROR - Phone number cannot begin with 555" << endl; break;
case -4: cout << "ERROR - Hyphen is not in the correct position" << endl; break;
case -5: return 0; break;
default: AcknowledgeCall(d1, d2, d3, d4, d5, d6, d7, d8);
}
}
return 0;
}
int readDials(int &d1, int &d2, int &d3, int &d4, int &d5, int &d6, int &d7, int &d8)
{
cout << "Enter the first digit of the phone number or Q to quit. " << endl;
cin >> d1;
char q =0, Q=0;
if (d1 == q || d1 == Q)
return -5;
cout << "Please enter the entire number " << endl;
cin >> d1 >> d2 >> d3 >> d4 >> d5 >> d6 >> d7 >> d8;
int result = ToDigit(d1, d2, d3, d4, d5, d6, d7, d8);
if(result == -1)
return -1;
if(result == -2)
return -2;
if(result == -3)
return -3;
if(result == -4)
return -4;
else if ( result != -1 || result != -2 || result != -3 || result != -4)
return -5;
return result;
}
int ToDigit(int &d1, int &d2, int &d3, int &d4, int &d5, int &d6, int &d7, int &d8)