Write a program to be used in a cannon training simulation. The user will enter
ID: 3542194 • Letter: W
Question
Write a program to be used in a cannon training simulation. The user will enter the speed the cannon shoots, the angle it is aimed, and the x and y coordinates of the target. The program will determine if the target is hit or missed and if missed will give advice as to what direction to tilt the cannon (up or down) in order to move closer to the target. * You are to write computer code that a user can use in response to the given problem. You can use any programing language that you would like to be able to run your code. Recommended languages are: Python, MatLab, or Excel. Write a program to be used in a cannon training simulation. The user will enter the speed the cannon shoots, the angle it is aimed, and the x and y coordinates of the target. The program will determine if the target is hit or missed and if missed will give advice as to what direction to tilt the cannon (up or down) in order to move closer to the target. * You are to write computer code that a user can use in response to the given problem. You can use any programing language that you would like to be able to run your code. Recommended languages are: Python, MatLab, or Excel.Explanation / Answer
Hi ,
I have written some python code, but i not sure about my physics properly.
import math
angle = float(input("Enter the angle >>>"));
print angle;
vi = float(input("Enter the initial velocity >>> "));
givenx = float(input("Enter the X Coordinate >>> "));
giveny = float(input("Enter the Y Coordinate >>> "));
vx = vi * math.cos(angle);
vy = vi * math.sin(angle);
t = givenx/ vx ;
y = vy * t - (4.9)*t*t;
if(y == giveny ):
print "hit";
elif (y> giveny):
print "miss , aim higher";
elif (y<giveny):
print "miss , aim lower";
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.