Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement We encounter projectile motion whenever we attempt to catch a fly ball, hit a long drive, or shoot a free throw. The laws

Problem Statement

We encounter projectile motion whenever we attempt to catch a fly ball, hit a long drive, or shoot a free throw. The laws of physics, which describe projectile motion, are well known. They were first studied by Napoleons generals. To simplify the problem, we will assume that we can

- consider the surface of the Earth to be a plane

- ignore the effect of the drag from air friction

Under the simplifying conditions above, the following formulas hold for a projectile with an initial velocity of v feet/sec and a launch angle of r (note that these expressions are not written according to the syntax of the Java language).

- Timespan of the flight: T = 2 v sin r / g

- Maximum height: ymax = (v sin r) t - 12 g t2, where t = T/2

- Range (distance traveled by the projectile): xmax = (v cos r) T

Here g is the gravitational acceleration g = 32 ft/sec2 (in English units) and r is measured in radians. This project simulates the process of repeated attempts to hit a target with a projectile. The goal is to shoot the projectile within a 1-foot distance from the target since such a short miss is accepted as a hit. You will construct a Java program that

  • can determine the trajectory data of a projectile for a given initial velocity and a launch angle, in particular for an initial choice of a 45-degree angle

  • can check if the initial attempt overshoots the target with more than 1 foot; if so the process is terminated and then restarted with an increased initial velocity (note that for any initial velocity the longest range is attained if the launch angle is of 45 degrees)

  • can determine the error of a shot (error = projectile range distance to target)

  • can check if the error is less than 1 foot in absolute value; if so, the user is notified about

    the result and the process terminates

  • can offer the user four chances to modify the launch angle and try to hit the target

  • can keep track of the smallest error produced by the subsequent attempts; the best result

    is reported to the user

    Analysis and requirements

    The analysis describes the logical structure of the problem in a way that helps us to plan (design) a solution.

    Input

    Initial input values are (i) initial velocity (feet/sec)

    (ii) distance to the desired target (feet) (iii) the gravitational acceleration (a constant)

    Additional input values are the launch angles for the repeated attempts if applicable. The angle must always be in the range of 0.0 45.0 degrees. Distance, velocity, and launch angle are solicited from the user on JOptionPane input windows.

Each report must contain

(1) the initial velocity in feet/sec; (2) the current launch angle in degrees; (3) the flight time in seconds; (4) the maximum height attained; (5) the distance traveled by the projectile (range); (6) the error with which the projectile missed the target

Design

For this project, you shall design a single class that contains all the necessary data and operations. A suggested class name is Projectile. You must decide upon the necessary import(s).

The Projectile class contains the main method, which in turn contains all the variable declarations. The main method should carry out the following tasks in the order given:

  • declares and assigns a named constant for the gravitational acceleration; the value is 32

  • solicits and stores the input values as explained in the Analysis section

  • computes all the trajectory data and saves those in variables

  • builds up and stores the output message in a single string variable (content of Figures 4, 8)

  • displays the output windows

  • numbers in the output are formatted to the nearest hundredth; for this purpose, the String.format( ) and printf( ) methods are used

  • uses if and/or if-else logic to decide if additional launches are necessary and repeat the operations at most for times if needed

  • terminates the program when it is due

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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

Students also viewed these Databases questions