i need to write something like this and im getting errors
need help
can anyone correct it so i can see how you did that thats the best way for me to learn
[k_maslon1@mars ~]$ g++ shooting_guy.cpp
shooting_guy.cpp: In function `int main()':
shooting_guy.cpp:30: error: invalid operands of types `double' and `<unresolved overloaded function type>' to binary `operator*'
shooting_guy.cpp:31: error: invalid operands of types `double' and `<unresolved overloaded function type>' to binary `operator*'
shooting_guy.cpp:32: error: invalid operands of types `double' and `<unresolved overloaded function type>' to binary `operator*'
shooting_guy.cpp:32: error: `5.0e-1' cannot be used as a function
shooting_guy.cpp:32: error: expected `)' before ';' token
shooting_guy.cpp:38: error: expected `}' at end of input
shooting_guy.cpp:38: error: expected `}' at end of input
[k_maslon1@mars ~]$
double T = R/(velKPH*cos*angleRad);
double X = (velKPH*cos*angleRad)*T;
double Y = (velKPH*sin*angleRad)*T-(0.5(g)(pow(T,2.0));
I think you forgot the () for cos and sin on these lines. They are functions, but without the (), your implying they are variables that you never declared.
Better formatting of your code will help to spot syntax errors too.
And i need to write a program for my hw
some guy is shooting and i need to calculate: total distance how far he will fly, total time,x distance, y distance.
for input needs to be Angle in degrees and velocity kPH [0,infinity)
for progress:R = (pow(velKPH,2.0)/g)*sin(2.0*angleRad);
T = R/(velKPH*cos*angleRad);
X = (velKPH*cos*angleRad)*T;
Y = (velKPH*sin*angleRad)*T-(0.5(g)(pow(T,2.0));
you mean i have two write like this?
double T = R/(velKPH*(cos)*angleRad);
double X = (velKPH*(cos)*angleRad)*T;
double Y = (velKPH*(sin)*angleRad)*T-(0.5(g)(pow(T,2.0));
you mean i have two write like this?
double T = R/(velKPH*(cos)*angleRad);
double X = (velKPH*(cos)*angleRad)*T;
double Y = (velKPH*(sin)*angleRad)*T-(0.5(g)(pow(T,2.0));
No.
R = (pow(velKPH,2.0)/g)*sin(2.0*angleRad);
T = R/(velKPH*cos*angleRad);
X = (velKPH*cos*angleRad)*T;
Y = (velKPH*sin*angleRad)*T-(0.5(g)(pow(T,2.0));
sin and cos are functions. You called them like so:
sin(number);
cos(number;
Where number is the angle in radians.
You used sin as a function in the first line here, then neglect to use it and cos as functions in the lines that follow.
I suspect you are missing a '}' or two in there too, which is why better formatting practices will help. I think your while loops aren't closed.
shooting_guy.cpp:32: error: `5.0e-1' cannot be used as a function
shooting_guy.cpp:32: error: expected `)' before ';' token
shooting_guy.cpp:38: error: expected `}' at end of input
shooting_guy.cpp:38: error: expected `}' at end of input
thank you