Question
Overview You are a part of a team that will be completing at a Catapult Contest. Your team will be attacking the castle. The goal
Overview
You are a part of a team that will be completing at a Catapult Contest. Your team will be attacking the castle. The goal is to launch the catapult over the wall surrounding the castle but not go beyond the far castle wall. To help, you need to write a program to calculate the trajectory of a projectile based on launch angles and launch velocities. It will create a matrix to help your team hit the target range. Review the information about calculating projectile trajectories in the Background Information section below. Look up the toRadians() and the sin() methods in the Java API for the Math class. Remember, the sin() method parameter must be in radians. Take time to plan your project. The program must use an OOP design.
Requirements
Rules
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 the near and far castle walls, the program should search the calculated trajectories and return a list of speed and angle combinations that can be used by your team to successfully launch the catapult. The output should be in an easy to read human readable format. If there are no speed and angle pairs in the current set that will accomplish the goal in the current matrix, the program should also graciously tell the users that they do not have a viable launch. The program will have a number of potential sets of speeds and angles. The program should be able to run the simulation on as many times as indicated by the use. Input will be done from a text file rather than keyboard input.
The program will take input from a text file containing the following information on each line:
Number of sets
Number of speeds, followed by a list of speeds
Number of angles, followed by a list of angles
Minimum trajectory
Maximum trajectory
**speeds, angles, maximum and minimum repeated for the specified number of sets
Download the test data file linked from the same section as the assignment.
Expected Output:
When your program runs correctly, the program should output a table of possible distance values and under the table there should be a list of the speed and angle pairs that match. The format of the output table should resemble the following, but with the appropriate data for each row and column.
Java Requirements
The program must utilize single dimensional arrays to store the speeds and angles. At a minimum, you will need one 2D array to store the values for the trajectories. How you define the logic and utilize these arrays is up to you.
The program must be created from an object-oriented perspective. Most of the work should be completed in the object class. The program must use methods appropriately.
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.).
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) in meters 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. The final units should be in meters.
TEST DATA FILE:
7
16 27 28 57 60 88 98 124 153 157 164 169 191 203 214 226 232
19 4 8 15 17 36 42 43 47 52 53 58 60 62 64 70 72 78 81 90
88
209
7 19 34 78 89 110 198 236
5 16 50 64 65 73
55
184
10 9 23 31 54 134 138 153 174 184 229
16 4 5 14 19 23 34 46 51 55 62 69 74 77 83 85 87
85
313
10 1 29 98 106 112 162 189 190 214 218
9 7 10 25 65 70 78 81 88 89
91
284
3 113 148 227
13 6 29 34 46 54 64 65 69 71 72 75 78 82
94
199
10 19 23 61 63 85 105 123 171 205 250
16 2 8 11 17 25 31 32 37 52 64 67 68 79 80 82 87
96
190
6 43 94 102 170 188 241
2 69 89
57
334
Projectile Distance MPH 25 deg 30 deg 35 deg 40 deg 45 deg 50 deg 20 25 30 35 40 45 50 sin(2 where, vo is the launch speed is the launch angle, and g is the acceleration due to gravity Yo sin(20) Re 2 1 9.8ms 1600m2 (0 7660.sm 19.8m R 125m Projectile Distance MPH 25 deg 30 deg 35 deg 40 deg 45 deg 50 deg 20 25 30 35 40 45 50 sin(2 where, vo is the launch speed is the launch angle, and g is the acceleration due to gravity Yo sin(20) Re 2 1 9.8ms 1600m2 (0 7660.sm 19.8m R 125mStep 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