### Function does not take arguments

Hey guys this is a very ruff work on a program that I am doing for my class. Generally I have to make a program to compute four different things. I also need to create a menu, have a customer service representative take down the points and pass it to an engineer to do the calculations.. this is all using functions with C++

I have pretty much finished the functions (might not be perfect), but I am just having a few issues with calling functions in my main program.. any help would be greatly appreciated.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255`` ``````#include #include using namespace std; int DisplayMenu(); double computeDistance(double pointxI, double pointxII, double pointyI, double pointyII); double computeHorizontalangle(double pointxI, double pointxII, double pointyI, double pointyII); double HorizontalDistance(double elevationAngleD, double velocityMiles); double computeDestination(double pointxI, double pointyI, double pointDistance, double horizontalAngleD, double &destinationX, double &destinationY); void customerService(int programChoice, double &pointxI, double &pointxII, double &pointyI, double &pointyII, double &elevationAngleD, double &velocityMiles, double &pointDistance, double &horizontalAngleD); double engineer(int programChoice, double pointxI, double pointxII, double pointyI, double pointyII, double elevationAngleD, double velocityMiles, double pointDistance, double horizontalAngleD); void displayResults(int programChoice, double pointDistance, double degreeAngle, double horizontalDistanceF, double destinationX, double destinationY); void main(void) { double pointxI, pointxII, pointyI, pointyII, elevationAngleD, velocityMiles, pointDistance, horizontalAngleD; cout << endl << "Compute Different Awesome Equations" << endl << endl; DisplayMenu(); customerService(pointxI, pointxII, pointyI, pointyII, elevationAngleD, velocityMiles, pointDistance, horizontalAngleD); } double computeDistance(double pointxI, double pointxII, double pointyI, double pointyII) { double pointDistance; pointDistance = sqrt(pow(pointxII - pointxI, 2) + pow(pointyII - pointyI, 2)); return pointDistance; } double computeHorizontalangle(double pointxI, double pointxII, double pointyI, double pointyII) { const double PI = 3.14159; double distanceX, distanceY, radianAngle, degreeAngle; distanceX = pointxII - pointxI; distanceY = pointyII - pointyI; if (distanceX > 0) { radianAngle = atan(distanceY / distanceX); } else if (distanceX < 0) { radianAngle = atan(distanceY / distanceX) + PI; } else if (distanceX = 0 && distanceY >= 0) { radianAngle = PI/2; } else { radianAngle = -PI/2; } degreeAngle = radianAngle * (180/PI); return degreeAngle; } double HorizontalDistance(double elevationAngleD, double velocityMiles) { const double gravity = 32.172, FeetperMile = 5280, SecsperHour = 3600, PI = 3.141519; double elevationAngleR, velocityFeet, horizontalDistanceF; elevationAngleR = elevationAngleD * (PI / 180); velocityFeet = velocityMiles * (FeetperMile / SecsperHour); horizontalDistanceF = pow(velocityFeet, 2) * sin(2 * elevationAngleR) / gravity; return horizontalDistanceF; } double computeDestination(double pointxI, double pointyI, double pointDistance, double horizontalAngleD, double &destinationX, double &destinationY) { const double PI = 3.14159; double horizontalAngleR, distanceX, distanceY; horizontalAngleR = horizontalAngleD * (PI / 180); distanceX = pointDistance * cos(horizontalAngleR); distanceY = pointDistance * sin(horizontalAngleR); destinationX = pointxI + distanceX; destinationY = pointyI + distanceY; return 0; } int DisplayMenu() { int programChoice; do { cout << endl; cout << "Choose from the following options: " << endl; cout << "(1) Compute the distance between two points" << endl; cout << "(2) Compute the horizontal angle of two points" << endl; cout << "(3) Compute the (horizontal) distance (in feet)" << " that an object travels" << endl; cout << "(4) Compute destination point" << endl; cout << "(5) Exit the program" << endl; cout << "Please enter your selection: "; cin >> programChoice; if (programChoice > 5 || programChoice < 0) { cout << endl << "Please enter a number from 1 to 5"; cout << endl << endl; } } while (programChoice > 5 || programChoice < 0); return programChoice; } double engineer(int programChoice, double pointxI, double pointxII, double pointyI, double pointyII, double elevationAngleD, double velocityMiles, double pointDistance, double horizontalAngleD, double destinationX, double destinationY) { if (programChoice == 1) { computeDistance(pointxI, pointxII, pointyI, pointyII); } else if (programChoice == 2) { computeHorizontalangle(pointxI, pointxII, pointyI, pointyII); } else if (programChoice == 3) { HorizontalDistance(elevationAngleD, velocityMiles); } else if (programChoice == 4) { computeDestination(pointxI, pointyI, pointDistance, horizontalAngleD, destinationX, destinationY); } return 0; } double customerSevice(int programChoice, double &pointxI, double &pointxII, double &pointyI, double &pointyII, double &elevationAngleD, double &velocityMiles, double &pointDistance, double &horizontalAngleD) { if (programChoice == 1 || programChoice == 2) { cout << endl << "Please enter your first x point: "; cin >> pointxI; cout << endl << "Please enter your second x point: "; cin >> pointxII; cout << endl << "Please enter your first y point: "; cin >> pointyI; cout << endl << "Please enter your second y point: "; cin >> pointyII; cout << endl << "Thank you!" << endl; } else if (programChoice == 3) { do { cout << endl << "Please enter the elevation angle: "; cin >> elevationAngleD; if (elevationAngleD < 0 || elevationAngleD > 90) { cout << endl << "Please inpute an angle between 0 - 90 degrees"; cout << endl << endl; } } while (elevationAngleD < 0 || elevationAngleD > 90); do { cout << endl << "Please enter the velocity: "; cin >> velocityMiles; if (velocityMiles < 0) { cout << endl << "Please enter a positive velocity"; cout << endl << endl; } } while (velocityMiles < 0); cout << endl << "Thank You!" << endl; } else if (programChoice == 4) { cout << endl << "Please enter your x point: "; cin >> pointxI; cout << endl << "Please enter your y point: "; cin >> pointyI; do { cout << endl << "Please enter your distance: "; cin >> pointDistance; if (pointDistance < 0) { cout << endl << "Please enter a positive distance"; cout << endl << endl; } } while (pointDistance < 0); do { cout << endl << "Please enter your horizontal angle: "; cin >> horizontalAngleD; if (horizontalAngleD < 0 || horizontalAngleD > 360) { cout << endl << "Please enter an angle between 0 - 360 degrees"; cout << endl << endl; } } while (horizontalAngleD < 0 || horizontalAngleD > 360); } return 0; } void displayResults(int programChoice, double pointDistance, double degreeAngle, double horizontalDistanceF, double destinationX, double destinationY) { if (programChoice == 1) { cout << "The distance between your two points is: " << pointDistance << endl; } else if (programChoice == 2) { cout << "The horizontal angle from the first point to the second point is: " << degreeAngle << endl; } else if (programChoice == 3) { cout << "The horizontal distance (in feet) the object traveled is: " << horizontalDistanceF << endl; } else if (programChoice == 4) { cout << "The destination point is: (" << destinationX << "," << destinationY << ")" << endl; } }``````

like I said this is a very ruff draft of the main program we are going to be writing..

but the error I have been getting is

error C2660: 'customerService' : function does not take 8 arguments

I know it has to be something I am doing wrong in terms of calling the function with the parameters.. but I can't figure it out.. and I stopped with the customerService function because I know if I am having issues with this one I am sure I will have issues calling the other ones.

Thanks in advance guys!!
What you want to do is pass the choice the user made in DisplayMenu() to customerService(). What you do now is discard that choice and call customerService() leaving out the first parameter: the choice.

This is a possible (and the shortest) solution:
 `` `` ``customerService( DisplayMenu(), pointxI, pointxII, pointyI, pointyII, elevationAngleD, velocityMiles, pointDistance, horizontalAngleD);``

See? The return value of DisplayMenu() is passed to customerService as parameter.

By the way: always declare your main function as `int main` and add `return 0;` at the end.
Last edited on
Topic archived. No new replies allowed.