C++ homework/project help
leishi85
Grand Rapids, MI Icrontian
i am in my dorm doing my hw for engineering 101 that is due tomorrow.
here is the project/hw detail
https://sitka.engin.umich.edu/EngineeringEducation/Eng101/Fall2004/Assignments/assignment2
below is what i got so far.
i'm having trouble to code it to calculate the angle i need to find. any help would be apperciated.
here is the project/hw detail
https://sitka.engin.umich.edu/EngineeringEducation/Eng101/Fall2004/Assignments/assignment2
below is what i got so far.
i'm having trouble to code it to calculate the angle i need to find. any help would be apperciated.
#include <iostream> #include <cmath> using namespace std; double aimingAngle(double A, double T, double D); void determineTrajectory(double x1, double y1, double x2, double y2, double D, double & A, double & T) int main() { cout << "Input an x y pair for the first point on the trajectory :> "; cin >> x1 >> y1; cout << "Input an x y pair for the second point on the trajectory :> "; cin >> x2 >> y2; cout << "Input the distance for the mortar :> "; cin >> D; } void determineTrajectory(double x1, double y1, double x2, double y2, double D, double & A, double & T) { double C; C = (y2 * (x1 - D)) / (y1 * (x2 - D)); T = (x1 * C - x2) / (C - 1); A = y1 / ((x1 - T) * (x1 - D)); } double aimingAngle(double A, double T, double D) }
0
Comments
[php]
#include <iostream>
#include <cmath>
using namespace std;
double aimingAngle(double A, double T, double D);
void determineTrajectory(double x1, double y1, double x2, double y2, double D, double& A, double& T);
int main()
{
cout << "Input an x y pair for the first point on the trajectory :> ";
cin >> x1 >> y1;
cout << "Input an x y pair for the second point on the trajectory :> ";
cin >> x2 >> y2;
cout << "Input the distance for the mortar :> ";
cin >> D;
return 0;
}
void determineTrajectory(double x1, double y1, double x2, double y2, double D, double& A, double& T)
{
double C;
C = (y2 * (x1 - D)) / (y1 * (x2 - D));
T = (x1 * C - x2) / (C - 1);
A = y1 / ((x1 - T) * (x1 - D));
}
double aimingAngle(double A, double T, double D)
{
}
[/php]
this code is far from done, i still haven't calculate for the aimingAngle, and i still need to out the answer to the user.
i'm just stuck on the part to calculate the aimingAngle
here is the final version
[PHP]
#include <iostream>
#include <cmath>
using namespace std;
double aimingAngle(double A, double T, double D);
void determineTrajectory(double x1, double y1, double x2, double y2, double D, double & A, double & T);
int main()
{
double x1, y1, x2, y2, D, A, T;
cout << "Input an x y pair for the first point on the trajectory :> ";
cin >> x1 >> y1;
cout << "Input an x y pair for the second point on the trajectory :> ";
cin >> x2 >> y2;
cout << "Input the distance for the mortar :> ";
cin >> D;
determineTrajectory(x1, y1, x2, y2, D, A, T);
double angle = aimingAngle(A, T, D);
cout << "The trajectory is " << A << "(x - " << T << ")(x - " << D << ") " << endl;
cout << " The aiming angle is: " << angle << " radians" << endl;
return 0;
}
void determineTrajectory(double x1, double y1, double x2, double y2, double D, double & A, double & T)
{
double C;
C = (y2 * (x1 - D)) / (y1 * (x2 - D));
T = (x1 * C - x2) / (C - 1.0);
A = y1 / ((x1 - T) * (x1 - D));
}
double aimingAngle(double A, double T, double D)
{
double X = ( D - T ) / 2.0 + T;
double Y = A * ( X - T ) * ( X - D );
double aimingAngle = atan2(Y,X);
return aimingAngle;
}
[/PHP]
(Note: leishi, I copied your final program directly (cuz I wanted to see it ) so this isn't a structure problem) sorry to thread crap, btw, just extremely frustrated lol. Oh, and I have no idea why it's saying that .... 1) there's no such dir 2) \C++ projects isn't where either the files are saved nor the program installed
i uploaded the code as txt file, and u can try open the file with your program and then try to compile it.
I am thinking from what you said about the files arent in the same directory is that your project folder is in the above folder your program mentioned and your files are in another.
Make a new project/solution/etc and copy the code in. Just make sure the program knows what to compile.
You could try compiling, running, maybe linking in separate steps.