I have spent days creating this program from psuado and origially had over sixty errors but now I am only down to four, but I don't understand them can anyone help?
int main()
{
char d1, d2, d3, d4, d5, d6, d7, d8;
int returnValue = 0;
while (returnValue != -5)
{
returnValue = readDials(int d1, int d2, int d3, int d4, int d5, int d6, int d7, int 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;
case -5: return 0;
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)
{
char q, Q;
cout << "Enter the first digit of the phone number or Q to quit. " << endl;
cin >> d1;
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(int d1, int d2, int d3, int d4, int d5, int d6, int d7, int 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;
}
int ToDigit(int d1, int d2, int d3, int d4, int d5, int d6, int d7, int d8)
switch ( d1, d2, d3, d5, d6, d7, d8)
{
case 'a':
cout << "2";
break;
case 'A':
cout << "2";
break;
case 'b':
cout << "2";
break;
case 'B':
cout << "2";
break;
case 'c':
cout << "2";
break;
case 'C':
cout << "2";
break;
case 'd':
cout << "3";
break;
case 'D':
cout << "3";
break;
case 'f':
cout << "3";
break;
case 'F':
cout << "3";
break;
case 'g':
cout << "4";
break;
case 'G':
cout << "4";
break;
case 'h':
cout << "4";
break;
case 'H':
cout << "2";
break;
case 'i':
cout << "4";
break;
case 'I':
cout << "4";
break;
case 'j':
cout << "5";
break;
case 'J':
cout << "5";
break;
case 'k':
cout << "5";
break;
case 'K':
cout << "5";
break;
case 'l':
cout << "5";
break;
case 'L':
cout << "5";
break;
case 'M':
cout << "6";
break;
case 'm':
cout << "6";
break;
case 'o':
cout << "6";
break;
case 'O':
cout << "6";
break;
case 'p':
cout << "7";
break;
case 'P':
cout << "7";
break;
case 'q':
cout << "7";
break;
case 'Q':
cout << "7";
break;
case 'r':
cout << "7";
break;
case 'R':
cout << "7";
break;
case 's':
cout << "7";
break;
case 'S':
cout << "7";
break;
case 't':
cout << "8";
break;
case 'T':
cout << "8";
break;
case 'u':
cout << "8";
break;
case 'U':
cout << "8";
break;
case 'v':
cout << "8";
break;
case 'w':
cout << "9";
break;
case 'W':
cout << "9";
break;
case 'x':
cout << "9";
break;
case 'X':
cout << "9";
break;
case 'y':
cout << "9";
break;
case 'Y':
cout << "9";
break;
case 'z':
cout << "9";
break;
case 'Z':
cout << "9";
break;
return 0;
}
}
void AcknowledgeCall(int d1, int d2, int d3, int d4, int d5, int d6,int d7, int d8)
{
cout << " The number is " << d1 << d2 << d3 << d4 << d5 << d6 << d7 << d8 << endl;
}
The errors are:
1>------ Build started: Project: LAB4, Configuration: Debug Win32 ------
1>Compiling...
1>LAB4.cpp
1>c:\users\ben\documents\visual studio 2008\projects\lab4\lab4\lab4.cpp(20) : error C2144: syntax error : 'int' should be preceded by ')'
1>c:\users\ben\documents\visual studio 2008\projects\lab4\lab4\lab4.cpp(20) : error C2660: 'readDials' : function does not take 0 arguments
1>c:\users\ben\documents\visual studio 2008\projects\lab4\lab4\lab4.cpp(20) : error C2059: syntax error : ')'
1>c:\users\ben\documents\visual studio 2008\projects\lab4\lab4\lab4.cpp(42) : error C2144: syntax error : 'int' should be preceded by ')'
1>c:\users\ben\documents\visual studio 2008\projects\lab4\lab4\lab4.cpp(42) : error C2660: 'ToDigit' : function does not take 0 arguments
1>c:\users\ben\documents\visual studio 2008\projects\lab4\lab4\lab4.cpp(42) : error C2059: syntax error : ')'
1>Build log was saved at "file://c:\Users\Ben\Documents\Visual Studio 2008\Projects\LAB4\LAB4\Debug\BuildLog.htm"
1>LAB4 - 6 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
You will have a few more errors than that but to get you stated:
1>c:\users\ben\documents\visual studio 2008\projects\lab4\lab4\lab4.cpp(20) : error C2144: syntax error : 'int' should be preceded by ')'
referes to this line: returnValue = readDials(int d1, int d2, int d3, int d4, int d5, int d6, int d7, int d8);
as you are calling the function you should not be including the ints returnValue = readDials(d1, d2, d3, d4, d5, d6, d7, d8);
you do the same elswhere in your code.
Also d1, d2 el al are defined as char the should be int if you are passing them into the function, They should also be initialised i.e. int d1 =0;
Your prototype for int readDials(int, int, int, int, int, int, int, int); doesn't include the reference character & for each parameter. So the method signature does not match the implementation.