Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Problem: You are working on an application for the Navy to determine the correct angle for Battleship guns to be aimed so that they

The Problem: You are working on an application for the Navy to determine the correct angle for Battleship guns to be aimed so that they hit their target. The U.S. Navy wants to use this application to gain a competitive advantage over other navies who are still using really quick mathematicians. The range of the Battleship shells can be determined using the following formula: R = (Muzzle Velocity squared/ gravity) (sine (2*Gun Muzzle Angle)). The Muzzle Velocity of a Battleship gun is a constant 853.44 meters/second. Gravity is also a constant, at 9.8 meters per second squared. Be sure to create constant variables whenever it is appropriate. Battleship guns angle can be adjusted from 1 to 35 degrees. The java.lang.Math class needs to be used to covert the degrees to radians and then to take the sine of that. Those methods are represented in the example below. For example, if the muzzle angle is 31 degrees, the range R is 65,622.81 R = ((853.44 * 853.44) / 9.8) (Math.sin( Math.toRadians(2 * 31) )) R = (728,359.83/9.8) (Math.sin(Math.toRadians(62))) R = (74,322.43) (.8829) R = 65,622.81 Your application will first ask the user how far away (i.e. the range) the enemy ship is (in meters), and then it will calculate the best angle to position the guns. The best angle to position the guns is the angle that is within plus or minus 10 meters of the enemy ship. The first angle that comes within this tolerance should be listed in the output as the best possible angle and no further angle ranges should be calculated. If no angle comes within this tolerance, then the message "The enemy ship cannot be hit at this distance". Sample input and output (user input is in green): Naval Gunnery Helper! Please enter the distance (in meters) to the enemy ship: 64365 With the gun at angle 1 the projectile will travel 2,593.815 meters, so the enemy ship will not be hit

2 With the gun at angle 2 the projectile will travel 5,184.471 meters, so the enemy ship will not be hit With the gun at angle 3 the projectile will travel 7,768.81 meters, so the enemy ship will not be hit With the gun at angle 4 the projectile will travel 10,343.683 meters, so the enemy ship will not be hit With the gun at angle 5 the projectile will travel 12,905.955 meters, so the enemy ship will not be hit With the gun at angle 6 the projectile will travel 15,452.503 meters, so the enemy ship will not be hit With the gun at angle 7 the projectile will travel 17,980.224 meters, so the enemy ship will not be hit With the gun at angle 8 the projectile will travel 20,486.039 meters, so the enemy ship will not be hit With the gun at angle 9 the projectile will travel 22,966.895 meters, so the enemy ship will not be hit With the gun at angle 10 the projectile will travel 25,419.769 meters, so the enemy ship will not be hit With the gun at angle 11 the projectile will travel 27,841.673 meters, so the enemy ship will not be hit With the gun at angle 12 the projectile will travel 30,229.656 meters, so the enemy ship will not be hit With the gun at angle 13 the projectile will travel 32,580.81 meters, so the enemy ship will not be hit With the gun at angle 14 the projectile will travel 34,892.268 meters, so the enemy ship will not be hit With the gun at angle 15 the projectile will travel 37,161.216 meters, so the enemy ship will not be hit With the gun at angle 16 the projectile will travel 39,384.888 meters, so the enemy ship will not be hit With the gun at angle 17 the projectile will travel 41,560.577 meters, so the enemy ship will not be hit With the gun at angle 18 the projectile will travel 43,685.629 meters, so the enemy ship will not be hit With the gun at angle 19 the projectile will travel 45,757.458 meters, so the enemy ship will not be hit With the gun at angle 20 the projectile will travel 47,773.538 meters, so the enemy ship will not be hit With the gun at angle 21 the projectile will travel 49,731.414 meters, so the enemy ship will not be hit With the gun at angle 22 the projectile will travel 51,628.7 meters, so the enemy ship will not be hit With the gun at angle 23 the projectile will travel 53,463.083 meters, so the enemy ship will not be hit

3 With the gun at angle 24 the projectile will travel 55,232.331 meters, so the enemy ship will not be hit With the gun at angle 25 the projectile will travel 56,934.286 meters, so the enemy ship will not be hit With the gun at angle 26 the projectile will travel 58,566.876 meters, so the enemy ship will not be hit With the gun at angle 27 the projectile will travel 60,128.111 meters, so the enemy ship will not be hit With the gun at angle 28 the projectile will travel 61,616.089 meters, so the enemy ship will not be hit With the gun at angle 29 the projectile will travel 63,028.997 meters, so the enemy ship will not be hit With the gun at angle 30 the projectile will travel 64,365.114 meters, and hit the enemy ship To hit the target, the gun should be set at 30 degrees. To quit, enter Q or q: Y Please enter the distance (in meters) to the enemy ship: 250000 With the gun at angle 1 the projectile will travel 2,593.815 meters, so the enemy ship will not be hit With the gun at angle 2 the projectile will travel 5,184.471 meters, so the enemy ship will not be hit With the gun at angle 3 the projectile will travel 7,768.81 meters, so the enemy ship will not be hit With the gun at angle 4 the projectile will travel 10,343.683 meters, so the enemy ship will not be hit With the gun at angle 5 the projectile will travel 12,905.955 meters, so the enemy ship will not be hit With the gun at angle 6 the projectile will travel 15,452.503 meters, so the enemy ship will not be hit With the gun at angle 7 the projectile will travel 17,980.224 meters, so the enemy ship will not be hit With the gun at angle 8 the projectile will travel 20,486.039 meters, so the enemy ship will not be hit With the gun at angle 9 the projectile will travel 22,966.895 meters, so the enemy ship will not be hit With the gun at angle 10 the projectile will travel 25,419.769 meters, so the enemy ship will not be hit With the gun at angle 11 the projectile will travel 27,841.673 meters, so the enemy ship will not be hit

4 With the gun at angle 12 the projectile will travel 30,229.656 meters, so the enemy ship will not be hit With the gun at angle 13 the projectile will travel 32,580.81 meters, so the enemy ship will not be hit With the gun at angle 14 the projectile will travel 34,892.268 meters, so the enemy ship will not be hit With the gun at angle 15 the projectile will travel 37,161.216 meters, so the enemy ship will not be hit With the gun at angle 16 the projectile will travel 39,384.888 meters, so the enemy ship will not be hit With the gun at angle 17 the projectile will travel 41,560.577 meters, so the enemy ship will not be hit With the gun at angle 18 the projectile will travel 43,685.629 meters, so the enemy ship will not be hit With the gun at angle 19 the projectile will travel 45,757.458 meters, so the enemy ship will not be hit With the gun at angle 20 the projectile will travel 47,773.538 meters, so the enemy ship will not be hit With the gun at angle 21 the projectile will travel 49,731.414 meters, so the enemy ship will not be hit With the gun at angle 22 the projectile will travel 51,628.7 meters, so the enemy ship will not be hit With the gun at angle 23 the projectile will travel 53,463.083 meters, so the enemy ship will not be hit With the gun at angle 24 the projectile will travel 55,232.331 meters, so the enemy ship will not be hit With the gun at angle 25 the projectile will travel 56,934.286 meters, so the enemy ship will not be hit With the gun at angle 26 the projectile will travel 58,566.876 meters, so the enemy ship will not be hit With the gun at angle 27 the projectile will travel 60,128.111 meters, so the enemy ship will not be hit With the gun at angle 28 the projectile will travel 61,616.089 meters, so the enemy ship will not be hit With the gun at angle 29 the projectile will travel 63,028.997 meters, so the enemy ship will not be hit With the gun at angle 30 the projectile will travel 64,365.114 meters, so the enemy ship will not be hit With the gun at angle 31 the projectile will travel 65,622.812 meters, so the enemy ship will not be hit With the gun at angle 32 the projectile will travel 66,800.559 meters, so the enemy ship will not be hit With the gun at angle 33 the projectile will travel 67,896.92 meters, so the enemy ship will not be hit

5 With the gun at angle 34 the projectile will travel 68,910.559 meters, so the enemy ship will not be hit With the gun at angle 35 the projectile will travel 69,840.241 meters, so the enemy ship will not be hit The enemy ship cannot be hit at this distance To quit, enter Q or q: Q Naval Gunnery Helper ended.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals of Thermodynamics

Authors: Richard E. Sonntag, Claus Borgnakke, Gordon J. Van Wylen

6th edition

471152323, 978-0471152323

More Books

Students also viewed these Physics questions