subject

Using the pseudo code below, write the code that will meet the requirements: Main Function
Declare the char variables for the 8 digits of the phone number
while true
Call the ReadDials function passing the 8 digits
by reference. ReadDials returns an error code by
value.
If the return value is -5, exit the do while loop
If the error code is -1, display the
error message "ERROR - An invalid character was entered".
If the error code is -2, display the
error message "ERROR - Phone number cannot begin with 0".
If the error code is -3, display the
error message "ERROR - Phone number cannot begin with 555".
If the error code is -4, display the
error message "ERROR - Hyphen is not in the correct position".
Otherwise, call the AcknowledgeCall function
End-While
ReadDials function
Input the first digit
If a Q was entered, return -5.
Input the rest of the phone number
Call the ToDigit function for each of the 7 digits
not for digit 4
If ToDigit returns -1, return -1
If digit 4 is not a hyphen, return -4.
If digit 1 is 0, return -2.
If digits 1 - 3 are 5, return -3
Otherwise, return 0
ToDigit function
Convert the digit to upper case
Use a switch statement to determine if the digit is valid
and convert the letters to digits
If the digit is invalid, return -1.
If the digit is valid, return 0.
AcknowledgeCall function
Display the Phone Number
this is what I got so far:
#include

using namespace std;

char ReadDials(char d1,char d2,char d3,char d4,char d5,char d6,char d7,char d8);//function prototype

ToDigit() function prototype
AcknowledgeCall() function prototype

int main()
{
char d1=0,d2=0,d3=0,d4=0,d5=0,d6=0,d7=0, d8=0;//declare variables for digits
cout<<"Enter digits, separated by a space.";
cin >> d1 >> d2 >> d3 >> d4 >> d5 >> d6 >> d7 >> d8;

while true
// Call the ReadDials function passing the 8 digits by reference. ReadDials returns an error code by value.
char ReadDials(d1,d2, d3, d4, d5, d6, d7, d8);//call ReadDials
char ReadDials(char d1, char d2, char d3, char d4, char d5, char d6, char d7, char d8);

if the return value is -5, exit the do while loop
if the error code is -1, display the error message "ERROR - An invalid character was entered";
if the error code is -2, display the error message "ERROR - Phone number cannot begin with 0";
if the error code is -3, display the error message "ERROR - Phone number cannot begin with 555";
if the error code is -4, display the error message "ERROR - Hyphen is not in the correct position";
if(d1=='Q'||'q')
return -5;

// Otherwise, call the AcknowledgeCall function
End-While

return 0;
}

//ReadDials function
char ReadDials(char d1, char d2, char d3, char d4, char d5, char d6, char d7, char d8);
{
cout<<"Enter first digit."< if a Q was entered, return -5;
cout<<"Enter the rest of the number."< // Call the ToDigit function for each of the 7 digits, not for digit 4
if ToDigit returns -1, return -1;
if digit 4 is not a hyphen, return -4;
if digit 1 is 0, return -2;
if digits 1 - 3 are 5, return -3;
return 0
}

ToDigit function
{
// Convert the digit to upper case
switch(c)
{
case '0': cout<< result+="0"; break;
case '1': cout<< result+="1"; break;
case '2': cout<< case 'a': case 'b': case 'c': result+="2"; break;
case '3': cout< case '4':cout<< case 'g': case 'h': case 'i': result+="4"; break;
case '5': cout< case '6':cout<< case 'm': case 'n': case 'o': result+="6"; break;
case '7': cout< case '8': cout< case '9': cout<
}

if the digit is invalid, return -1;
if the digit is valid, return 0;
}

AcknowledgeCall function
{
Display the Phone Number.
}
return 0;
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 05:00
Modern businesses use different technologies to accomplish work tasks
Answers: 2
question
Computers and Technology, 22.06.2019 11:00
Which law requires employers to provide safe working environments for their employees? a. civil rights act b. fair labor standards act c. occupational safety and health act d. wagner act
Answers: 1
question
Computers and Technology, 22.06.2019 19:10
How might the success of your campaign be affected if you haven’t carefully completed all field data or if you accidentally insert the wrong merge field in the document?
Answers: 1
question
Computers and Technology, 22.06.2019 20:10
Assume that minutes is an int variable whose value is 0 or positive. write an expression whose value is "undercooked" or "soft-boiled" or "medium-boiled" or "hard-boiled" or "overcooked" based on the value of minutes. in particular: if the value of minutes is less than 2 the expression's value is "undercooked"; 2-4 would be a "soft-boiled", 5-7 would be "medium-boiled", 8-11 would be "hard-boiled" and 12 or more would be a "overcooked".
Answers: 1
You know the right answer?
Using the pseudo code below, write the code that will meet the requirements: Main Function
D...
Questions
question
Mathematics, 23.11.2020 18:50
question
Mathematics, 23.11.2020 18:50
question
Mathematics, 23.11.2020 18:50
question
Mathematics, 23.11.2020 18:50
question
English, 23.11.2020 18:50
Questions on the website: 13722361