# Thread: Am stuck, need an expert?

1. ## Am stuck, need an expert?

Hello,

I have two assignments and they want you to write code to determine the distance of how far an individual will go with velocity known.

1)

Yikes the clown is going to be shot out of a cannon and needs to know where to put the safety net. Your mission is to write a C++ program to help him do this.
Yikes will enter his velocity in miles per hour, and the cannon angle in degrees. Your program will give him the distance (range) that he travels measured in feet.
Assume the following:
R = (v2 / g) sin(2Θ)
R = distance in feet
v = velocity in feet per second
Θ=cannon angle

2)

Given the success of his last stunt, Yikes the Clown is now going to attempt the following. He will ride down a hill on a skateboard and off a ramp at the bottom. He wants to know how fast he will be travelling when he leaves the ramp.
The formula for this is:
V=sqrt (2 g (h1  h2))
V is his velocity at the end of the ramp
g is acceleration due to gravity (either 9.8 m/s2 or 32 f/s2 depending on if you are using English or Metric).
h1 is the height of the hill in either meters or feet.
H2 is the height of the ramp in either meters or feet.
You may choose which unit of measure to do this assignment in.

:::::::::

I am attempting, but I have no idea. None. Professor wasn't much help. 2. Can you do question 1 on a calculator?
What is the answer if v is 50 miles per hour and theta is 20 degrees? 3. Originally Posted by john.c Can you do question 1 on a calculator?
What is the answer if v is 50 miles per hour and theta is 20 degrees?
I don't think he wants us to do it that way. 4. That's a pretty common approach though: figure out a mathematical formula, then write a program to implement and hence automate it. If that's not the way your professor intends, then what is intended? If you don't know and can't find out because your professor isn't helping, then you have a choice: either do something that works even if it isn't what you think your professor intended (in which case you have a fighting chance of a passing grade), or do nothing at all (and therefore definitely fail). 5. Originally Posted by laserlight That's a pretty common approach though: figure out a mathematical formula, then write a program to implement and hence automate it. If that's not the way your professor intends, then what is intended? If you don't know and can't find out because your professor isn't helping, then you have a choice: either do something that works even if it isn't what you think your professor intended (in which case you have a fighting chance of a passing grade), or do nothing at all (and therefore definitely fail).
Ok, do you know how to use putty? I don't have a clue...where to write the code...etc.

the equation I have is d= v^2/g * sin(2theta) 6. Originally Posted by john.c Can you do question 1 on a calculator?
What is the answer if v is 50 miles per hour and theta is 20 degrees? 7. Originally Posted by solidusMGS
Ok, do you know how to use putty?
Yes. Originally Posted by solidusMGS
I don't have a clue...where to write the code...etc.
That's something you have to sort out with the professor or other members of the teaching team. The forum members here cannot help you with the specifics beyond "write your code in an editor or IDE". 8. Originally Posted by laserlight Yes.

That's something you have to sort out with the professor or other members of the teaching team. The forum members here cannot help you with the specifics beyond "write your code in an editor or IDE".
Ok, what is x-ming for? I tried to install it and it says error code 5. 9. The X-ming says can't be deleted because x-ming is open on x-ming server..oh boy... 10. If you don't know what is it for, why are you trying to install it? 11. Originally Posted by laserlight If you don't know what is it for, why are you trying to install it?
I had it in my notes, so I googled it. Am going to go the system restore way now. Sucks. 12. Originally Posted by solidusMGS I don't think he wants us to do it that way.
I'm asking if you even understand the question. 13. Originally Posted by solidusMGS The answer should be in feet, not miles per hour. 14. Originally Posted by john.c I'm asking if you even understand the question.
No, I don't understand the question. 15. Originally Posted by john.c The answer should be in feet, not miles per hour.

You need to convert the given miles per hour into feet per second.
You need to convert the angle in degrees to the angle in radians (because the C library sin function takes radians).
So I think this is correct. The 32 is the acceleration due to gravity (g) in feet per second per second.

v = 50 miles per hour
angle = 20 degrees

fps = v * 5280 / 3600 = 73.333 fps
R = fps * fps / 32 * sin(2 * .3491) = 108.032 feet
How do I write that in C++? Like this?:

Code:
```#include<iostream>
#include<cmath>

constant double g=9.8;

int main()

{

double velocity=12;
cout<<"Enter a velocity?";
cin>>velocity;

double v=v*5280/3600 Popular pages Recent additions clown, feet, ramp, velocity, yikes 