Sep 27, 2012 at 5:13am UTC
Hey guys, new to c++ trying to get this code to work .. says candidate expects two arguments, 1 provided if you can skim over it.. thanks!
#include <iostream>
#include <cmath>
using namespace std;
int main (void)
{
float fA1= 0;
float fA2= 0;
float fD1= 0;
float fD2= 0;
float fV1i= 0;
float fV2i= 0;
double dV1= 0;
double dV2=0;
cout << "Enter the acceleration, distance, and and velocity of 1st object in this order." << endl;
cin>> fA1;
cin>> fD1;
cin>> fV1i;
if (fD1 <0)
{ cout << "distance can't be negative" << endl;
return 1;
}
//2nd object
cout << "Great, enter the acceleration, distance, and and velocity of 2nd object, in this order." << endl;
cin>> fA2;
cin>> fD2;
cin>> fV2i;
if (fD2 <0)
{ cout << "distance can't be negative" << endl;
return 1;
}
dV1= (pow((pow(fV1i),2) + 2*fA1*fD1),.5);
dV2= (pow((pow(fV2i),2) + 2*fA2*fD2),.5);
//test
if (dV1 > dV2)
{cout << "The first object has a greater velocity" << dV1 << endl;
if (dV1 < dV2)
{cout << "The second object has a greater velocity" << endl;
return 1;
}
if (dV1 == dV2)
{cout << "The 2 objects have an equal velocity " << endl;
return 1;
}
return 1;
}
return 0;
}
Sep 27, 2012 at 10:28am UTC
I don't see candidate anywhere in the code. Are you sure you get that error message from this code.
Sep 27, 2012 at 10:31am UTC
((pow(fV1i),2)
should be
pow(fV1i,2)
same with the line below
Last edited on Sep 27, 2012 at 10:32am UTC