I am taking this class through devry and that is my assignment for week four and this is my second attempt at the class..but this is what i got for this assignment..program compiles properly and runs...with no errors..got it from code snippet stealing from other classmates lol

# include <iostream>
# include <string>
# include <cctype>
# include <iomanip>
using namespace std;
// prototypes
int ReadDial (char &d1, char &d2, char &d3, char &d4, char &d5,char &d6, char &d7, char &d8);
char Todigit(char &d);
void AcknowledgeCall(char d1, char d2, char d3, char d4, char d5, char d6, char d7, char d8);

// function main
int main()
{
	char d1, d2, d3, d4, d5, d6, d7, d8;
	int returnValue = 0;
	while (returnValue != -5)
	{
		returnValue = ReadDial (d1, d2, d3, d4, d5, d6, d7, d8);
		switch (returnValue)
		{
		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;
		default: AcknowledgeCall (d1, d2, d3, d4, d5, d6, d7, d8);
		}
	}
	
	return 0;
}

// function ReadDial
int ReadDial (char &d1, char &d2, char &d3, char &d4, char &d5, char &d6, char &d7, char &d8)
{
    int returnValue;
    cout << "Enter a phone number (Q to quit): ";
    cin >> d1; 
    if(d1 == 'Q') return -5; 
    cin >> d2 >> d3 >> d4 >> d5 >> d6 >> d7 >> d8;  
    returnValue = Todigit(d1);
    if (returnValue == -1)
        return returnValue;
    returnValue = Todigit(d2);
    if (returnValue == -1)
        return returnValue;
    returnValue = Todigit(d3);
    if (returnValue == -1)
        return returnValue;
    if (d4 != '-')
        return -4;
    returnValue = Todigit(d5);
    if (returnValue == -1)
        return returnValue;
    returnValue = Todigit(d6);
    if (returnValue == -1)
        return returnValue;
    returnValue = Todigit(d7);
    if (returnValue == -1)
        return returnValue;
    returnValue = Todigit(d8);
    if (returnValue == -1)
        return returnValue;
    if (d1 == '0')
        return -2;
    if (d1 == '5' && d2 == '5' && d3 == '5')
        return -3;
    return 0;

}


//function ToDigit

char Todigit(char &d)
{
d = toupper(d);	
switch(d)
    {
        case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': break;
        case 'A': case 'B': case 'C': d = '2'; break;
        case 'D': case 'E': case 'F': d = '3'; break;
        case 'G': case 'H': case 'I': d = '4'; break;
        case 'J': case 'K': case 'L': d = '5'; break;
        case 'M': case 'N': case 'O': d = '6'; break;
		case 'P': case 'Q': case 'R': case 'S': d = '7'; break;
        case 'T': case 'U': case 'V': d = '8'; break;
		case 'W': case 'X': case 'Y': case 'Z': d = '9'; break;
        default: return -1;
    }
}


// function AcknowledgeCall
void AcknowledgeCall(char d1, char d2, char d3, char d4, char d5, char d6, char d7, char d8)
{


cout << "Phone Number Dialed: " << d1 << d2 << d3 << d4 << d5 << d6 << d7 << d8 << endl << endl;
}
jackmaverick1 commented: STEALING +0

Recommended Answers

All 2 Replies

We only give homework help to those who show effort

this is what i got for this assignment..program compiles properly and runs...with no errors..got it from code snippet stealing from other classmates lol

Don't feel bad they didn't help bigman91 3 months ago either and he made an effort. Although I don't approve of stealing, Mr. K didn't show much effort himself. You know, maybe point a guy in the right direction.
kimmyfufu check out: http://msdn.microsoft.com/en-us/visualc/aa336397.aspx
The forums are great and they may actually try to help you. Mr. K probably doesn't know the answer anyhow.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.