I'm not a C++ student, I'm self taught 14, and I wanted to make a program to solve my Geometry :p, like you've never tried.
So help soon would be
greatly appreciated before the section is over.
My compiler (Dev-C++) says the following error: "too few arguments to function `float DistanceCalc(float, float)'"
What is wrong. I'm trying to have the user input xone, xtwo, yone, and ytwo (x1, x2, y1, and y2 respectively). Then the functions take care of the rest (squaring, powering, adding, and subtracting), but the program hits the error when it comes to the simple addition...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
/*X1*/ float xone;
/*X2*/ float xtwo;
/*Y1*/ float yone;
/*X2*/ float ytwo;
/*XTOTAL*/ float xtotal;
/*YTOTAL*/ float ytotal;
/*XPOW*/ float xpow;
/*YPOW*/ float ypow;
/*XSQRT*/ float xsqrt;
/*YSQRT*/ float ysqrt;
/*DISTANCE*/ float Distance;
float xtotalCalc(float xone, float xtwo){
xtotal = xtwo - xone;
return (xtotal);}
float ytotalCalc(float yone, float ytwo){
ytotal = ytwo - yone;
return (ytotal);}
float xpowCalc(float xtotal){
xpow = xtotal * xtotal;
return (xpow);}
float ypowCalc(float ytotal){
ypow = ytotal * ytotal;
return (ypow);}
float xsqrtCalc(float xpow){
xsqrt = sqrt(xpow);
return (xsqrt);}
float ysqrtCalc(float ypow){
ysqrt = sqrt(ypow);
return (ysqrt);}
float DistanceCalc(float xsqrt, float ysqrt){ // <---------- Error
Distance = xsqrt + ysqrt;
return (Distance);}
int main(int argc, char *argv[])
{
cout << "Get started." << endl;
cout << "What are the following points: " << endl;
cout << "x1: ";
cin >> xone;
cout << endl << "x2: ";
cin >> xtwo;
cout << endl << "y1: ";
cin >> yone;
cout << endl << "y2: ";
cin >> ytwo;
cout << endl;
cout << "The distance to your problem is: " << DistanceCalc(Distance) << endl;
cin.ignore();
return EXIT_SUCCESS;
}
|
Go to PurpleMath.com to see the formula:
http://www.purplemath.com/modules/distform.htm