Uncategorized

PHONE DIALING PROGRAM IN C SHARP PROGRAMMING LANGUAGE

PHONE DIALING PROGRAM IN C SHARP PROGRAMMING LANGUAGE

I keep getting a lot of errors with this problem, not sure what I am doing wrong or have everything out of sorts but any suggestions would be awesome. This is supposed to be in C Sharp programming language and is for my C Sharp programming class that I am in. Here is the explanation of the homework assignment: Write a program that simulates the dial of a phone number. The program will input a phone number and the program will acknowledge the call by either writing an error message or the 8 digit phone number to the console window. The phone number may have either digits, letters, or both. Define a function named ReadDials() that reads each digit/letter dialed into 8 separate char variables (DO NOT USE ARRAYS). All digits are sent back through parameters by reference. Then, for each digit, the program will use a function named ToDigit(), which receives a single char argument (pass by reference) that may be a number or a letter of one of the digits dialed. If it is a number, return 0 by value indicating it is a valid digit. If the digit is a letter, the number corresponding to the letter is returned by reference and return 0 by value indicating it is a valid digit. Here are the letters associated with each digit. 0 5 J K L 1 6 M N O 2 A B C 7 P Q R S 3 D E F 8 T U V 4 G H I 9 W X Y Z If the digit entered is not one of the valid digits or valid letters, return 1 by value indicating that you have an invalid digit. A phone number never begins with a 0, so the program should flag an error if such a number is entered. Make ReadDials() return 2 in this case. Also a phone number never begins with 555, so the program should flag an error if such a number is entered. Make ReadDials() return 3 in this case. A phone number always has a hyphen (-) in the 4th position. Make ReadDials() return 4 if it doesnt have a hyphen in the 4th position. If a hyphen is in any other position, it is considered an invalid digit. If the phone number is valid, main calls the AcknowledgeCall function to write the converted number to the output file. All the logic of the program should be put in functions that are called from Main(): ReadDials(), and AcknowledgeCall(). The ToDigits() function is called from the ReadDials() function and is used to convert each letter entered individually to a digit and to verify the user has entered a valid phone number. Have the program work for any number of phone numbers. Continue processing until the user enters a Q. In the ToDigits() function use the toupper function to convert any letters entered to uppercase. All error messages are to be written to the output file from main() based on the return value from the functions. You will set up the 8 char variables to hold the digits of the phone number in main() and pass the variables to the functions by reference. Here is what I got so far: include include using namespace std; int ReadDials(char&,char&,char&,char&,char&,char&,char&,char&); int ToDigit( char &d); void AcknowledgeCall(char d1, char d2, char d3, char d4, char d5, char d6, char d7, char d8); int main() { char digit1= , digit2= , digit3= , digit4= , digit5= , digit6= , digit7= , digit8= ; int value; while (true) { value = ReadDials(digit1, digit2, digit3, digit4, digit5, digit6, digit7, digit8); switch (value) { case -1: cout>number; digit1 = number[0]; if (digit1 == Q) return 5; else { digit2 = number[1]; digit3 = number[2]; digit4 = number[3]; digit5 = number[4]; digit6 = number[5]; digit7 = number[6]; digit8 = number[7]; if (ToDigit( digit1) == -1) return -1; if (ToDigit( digit2) == -1) return -1; if (ToDigit( digit3) == -1) return -1; if (ToDigit( digit5) == -1) return -1; if (ToDigit( digit6) == -1) return -1; if (ToDigit( digit7) == -1) return -1; if (ToDigit( digit8) == -1) return -1; if (digit4 != -) return 4; else if (digit1 == 0) return 2; else if (digit1 == 5 && digit2 == 5 && digit3 == 5) return 3; else return 0; } } int ToDigit( char &d) { d = toupper(d); if (isdigit(d)) return 0; switch(d) { case A: case B: case C: d = 2; return 0; case D: case E: case F: d = 3; return 0; case G: case H: case I: d = 4; return 0; case J: case K: case L: d = 5; return 0; case M: case N: case O: d = 6; return 0; case P: case Q: case R: case S: d = 7; return 0; case T: case U: case V: d = 8; return 0; case W: case X: case Y: case Z: d = 9; return 0; } return -1; } void AcknowledgeCall(char d1, char d2, char d3, char d4, char d5, char d6, char d7, char d8) { cout

Is this the question you were looking for? If so, place your order here to get started!

×