whats the answer and explanation?
#CODE IN PYTHON
Hi There,
I am providing the code in Python and pictures to explain the question!
> the python file and the text file should be in the same folder
> Below is the code in which explanation is provided with the help of comments
import math
def distance(s,v,a):
pos=s
vel=v
vel=v**2 # Eg 3*3=9
angle=a
angle=2*a*0.0174533
angle=math.sin(angle) # Eg sin(angle)
d=0
d=(vel*angle)/9.8 # Projectile distance R is being calculated and
returned
return d
a=[]
f = open("projectiles.txt", "r") # File projectiles.txt is
opened
for x in f: #File is read line by line Eg 0 3 30
a=[]
d=0
a=x.split() # Line elements are splitted and stored in the list a
Eg a=['0','3','30']
d=distance(int(a[0]),int(a[1]),float(a[2])) # Distance function is
called Eg d=distance(0,3,30)
# Printing the values
print("for starting position: "+a[0]+",m velocity: "+a[1]+",m/s and
angle: "+a[2])
print("projectile hits a target distance "+str(d)+"m away from the
point "+a[0]+"m")
print()
> Now the image of a text file named projectiles.txt is provided
> Code image is provided in reference to the second image
> Output of the code is provided in the reference to the third image
TEXT FILE:
PROGRAM:
OUTPUT:
I hope it will help you! For any queries do reach out to me in the comment section!
-----------------------------------------------------------------------------------------------------------------------------------------------------------
# CODE IN JAVA
Hi There,
> Below I am providing the code in java too! as mentioned afterward.
CODE:
package extra;
import java.io.File;
import java.util.*;
import java.lang.Exception;
import java.lang.Math;
public class Extra {
public static double calculate(int v, int a)
{
double d;
double velocity=Math.pow(v,2);
double angle=2*a*0.0174533;
angle=Math.sin(angle);
d=(velocity*angle)/9.8; //Calculation of the distance
return d;
}
public static void main(String[] args) throws Exception
{
String token;
double x;
int a1,a2;
File file = new File("C:\\Users\\HP-PC\\Desktop\\projectiles.txt");
//file is opened
Scanner sc = new Scanner(file);
List<String> temps = new ArrayList<String>();
while (sc.hasNextLine())
{
token=sc.nextLine();
temps.add(token); //lines from text file are added to the
arraylist
}
String[] tempsArray = temps.toArray(new String[0]); //Arraylist is
converted to array
for (String s : tempsArray) {
System.out.println(s);
a1=Character.getNumericValue(s.charAt(2)); //Extracting
velocity
a2=Integer.parseInt(s.substring(4,6)); //Extracting Angle
x=calculate(a1,a2); //Function called
System.out.print("Distance: ");
System.out.println(x);
}
}
}
OUTPUT:
Hope that it will help you!
whats the answer and explanation? Programming 2 16. Write a program that reads in a set...
These questions are to be answered using MATLAB. I only
need #3 answered, but #1 provides information (like initial
velocity, etc.) required for the questions. I think I have it done,
but I'd like to see if there are other ways to use MATLAB for this
question.
PROJECTILES The distance a projectile travels when fired at an angle 8 is a function of time and can be divided into horizontal and vertical distances. Horizontal (1) = 1.V.cos(0) Vertical(t) = 1•...
Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the motion of an object projected into the air at an angle. The object flies in the air until the projectile returns to the horizontal axis (x-axis), where y=0. This MATLAB program should allow the user to try to hit a 2-m diameter target on the x-axis (y=0) by varying conditions, including the lunch direction, the speed of the lunch, the projectile’s size, and the...
I can't figure out how to change my code to write info in from a text file for the input. I'll post the context of the problem I am working on and the code I have finished so far. The program will create a Catapult object that will create a searchable matrix of trajectories for the given speeds and angles. The object should store these values in a 2D array. Given a target range of minimum and maximum distances, representing...
Projectile A is fired at a speed Vo at an angle 0 above horizontal as shown and projectile B is fired at the sar but at a speed of 2%. Use this for Questions #1-7. angle Draw the initial velocity vectors for both projectile A and projectile B. Remember that the length of your arrows is important. 1. 2. Compare the initial horizorntal and vertical velocities of projectiles A and B. Be specific. Explain your answers. 3. Compare the horizontal...
HW#5 Functions and Arrays
For HW#5 we will return to the state method of solving the
ballistic projectile problem with added twists. The goal will be to
hit a target 1000 meters east of your cannon but the wind is
blowing from the south. Your initial muzzle velocity is fixed at
110 meters per second, but you can control the elevation and
azimuth angles of your aim. Elevation angle is measured up or down.
Azimuth angle is measured right or...
5.15 PROGRAM: Functions - Upset Fowls (C++) (1) Correct the first FIXME by moving the intro text to the function stub named PrintIntro and then calling the PrintIntro function in main. Development suggestion: Verify the program has the same behavior before continuing. (2) Correct the second FIXME by completing the function stub GetUsrInpt and then calling this function in main. Notice that the function GetUsrInpt will need to return two values: fowlAngle and fowlVel. (3) Correct the third FIXME by...
5:16 lLTE ) Done 1 of 5 Assessment #1 (Kinematics of a Particle) Rectilinear Motion (Straight linc Motion 3. The position of a point during the interval of time from r otor 6 is given by ** * m. (a) What is the maximum velocity during this interval of time, and at what time does it occur? (b) What is the acceleration when the velocity is a maximum? (20 m/s, 0 m/s 3. A test projectile is fired horizontally into...
please answer all I beg you ASAP! and please try solving most of
them thabk you so much
Question 23 (1 point) At an instant a traffic light turns green, a truck starts with a constant acceleration of 1.8 m/s2. At the same moment a taxi travelling with a constant speed of 8.5 m/s overtakes and passes the truck. Which two equations properly describe the position of the truck and the taxi? a) dtruck = 8.5at dtaxi = 8.5at b)...
Please, I need help answering questions 10, 11, 12, 13, 14, and 15.
Use the other pages as information to solve the questions.
Use the questions below to keep track of key concepts from this lesson's study activity. YOUR ASSIGNMENT: Splatapults Away! The engineering club has built a catapult and wants to test it out. The local supermarket has donated some overripe fruits and vegetables, and now the club is holding a Splatapult challenge to see who can hit the...
The following guidelines outline the basic template for a robot vacuum cleaner game. The game must be implemented in c programming language. It mimics a robotic vacuum cleaner. The code must only use the following libraries: #include <math.h> #include <stdlib.h> #include <string.h> #include <limits.h> and any .graphics and .timers libraries. The guidelines are outlined as follows: Terminal Set-up: you may assume that the terminal will be quite large, for example, on the order of 150×50, or more. Status Display: The...