Question
I need an output similar to this image: As presented in picture, I should get distance of 410ft. at the velocity of 40mph with launch
I need an output similar to this image:
As presented in picture, I should get distance of 410ft. at the velocity of 40mph with launch angle of 25 degrees, but I get different output like my output below:
My code:
/** * This program calculates the trajectory of a projectile * based on launch angles and launch velocities. * */ public class CatapultApple { //local variables private int degreesNumber; private int velocitiesNumber; private double[][] output; private int[] degrees; private int[] velocities;
//constructor /** * CatapultApple constructor * * @param startDegree - start value for degrees * @param startVelocity - start value for velocity * @param degreesNum - number of degrees used * @param velocitiesNum - number of velocities used * @param degreeIncrement - the value to increment each degree * @param velocitiesInc - the value to increment each velocity */ CatapultApple(int startDegree, int startVelocity, int degreesNum, int velocitiesNum, int degreeIncrement, int velocitiesInc) { degreesNumber = degreesNum; velocitiesNumber = velocitiesNum; //degrees and velocities arrays degreesInit(startDegree, degreesNum, degreeIncrement); velocitiesInit(startVelocity, velocitiesNum, velocitiesInc); //calculate range calculateOutput(); }
//velocities array /** * creates an array for veolcities * * @param start - start value for velocities * @param number - number of velocities * @param increment - the value to increment velocities */ public void velocitiesInit(int start, int number, int increment) { velocities = new int[number];
int index = 0; for(int i = start; index
index++; } } //degrees array initializer /** * Creates the array of degrees * * @param start - start values for degrees * @param number - total number of degrees * @param increment - the value to increment the degrees * */ public void degreesInit(int start, int number, int increment) { degrees = new int[number]; int index = 0; for(int i = start; index
//calculate output array /** * Calculates two dimensional array of distances */ public void calculateOutput() { output = new double[velocitiesNumber][degreesNumber]; //assign each cell a value for(int y = 0; y
//print the results /** * Calculate and display the results in OOD format */ public void printResults() { //heading System.out.printf("%52s%n", "Projectile Distance (feet)"); System.out.println(); System.out.printf("%-12s", " MPH"); //print out the degrees for(int degree : degrees) { System.out.printf("%-12s", degree + " deg"); } //print out lines System.out.printf("%n="); for(int i = 0; i
public class CatapultAppleTester { public static void main(String[] args) { //create new with given dimensions and values CatapultApple table = new CatapultApple(25, 20, 6, 7, 5, 5); //print out statistics and data table.printResults(); } }
Background Information: Trajectory of a Projectile The distance (R) of a projectile can easily be calculated using the following simple algebraic formula, if a few complicating factors are ignored (e.g., wind speed, drag coefficient, etc.). Vo sin(20) R = g where, Vo is the launch speed, e is the launch angle, and g is the acceleration due to gravity v.sin(20) RE g ( 40m/s) sin(2-250) R 9.8m/s 1600m s? RE (0.7660 S R = 125m 100cm lin Ift R=125m m 2.54cm 12 in 3.2808ft R = 125m m R = 410ft 9.8m Suppose you could launch a projectile at a speed of 40 meters/second (about 90 miles per hour) and a launch angle of 25 degrees. How far down range (R) could the projectile be hurled? The solution for finding the down range distance of a projectile launched at a speed of 40 m/s and a launch angle of 25 is shown here. Be sure that you can work through the algebra and solve the equation with a calculator. Soon, you will turn it into an arithmetic expression in Java. Work out several answers with pencil, paper, and calculator first, before attempting to write the program. Pay close attention to units. If your speeds are miles per hour, convert them to meters per second. If you want your final result to be in feet, do that conversion, too. MPH 25 deg 30 deg 35 deg 40 deg 45 deg 50 deg 20 25 30 35 40 45 50 25.30 39.53 56.92 77.47 101.19 128.07 158.11 29.34 45.85 66.02 89.86 117.36 148.54 183.38 32.86 51.35 73.94 100.64 131.45 166.36 205.38 35.80 55.93 80.54 19962 143.18 181.21 223.72 38.09 59.52 85.70 116.65 152.36 192.83 238.06 39.71 62.04 89.34 121.60 158.82 201.01 248.16Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started