# Homework Solution: Your program must do the following in order to receive full credit on this assignme… Your program must do the following in order to receive full credit on this assignment. Ask the user to provide the following values which you will store as a double, one at a time, with a proper message for each (ie. "Please type in the height"). a. Velocity - The speed (in feet per second) at which the cannonball is fired. b. Angle - The angle (in degrees) above the ground at which the cannonball is fired (this is called the inclination angle in the above diagram). c. Distance This is the horizontal distance (in feet) to the target (RH in the above diagram) d. Elevation - The height (in feet) of the bottom of the target from the ground (y value on an x-y plane). e. Size - This is how tall the target is from its bottom (elevation) to its top (elevation + size). Validate the user's input. One of the calculations you need to do requires division and we must ensure that the denominator of the equation is not 0. a. Calculate (velocity * the cosine of angle in radians). i. Use the Math class for cosine and converting to radians. b. If that value if 0, print a message that the distance cannot be calculated with that input and do not continue. Otherwise, have the program continue to the next step. i. That is, the rest of the program should be in an else block. C. Calculate the time it takes the object to reach the distance. a. The formula is (distance/ (velocity * the cosine of angle in radians). d. Calculate the height of the projectile at the distance. a. The formula is (velocity *time *the sine of the angle in radians - ((32.17 * time squared)/2)) i. Again, use the math class for the sine and squaring time. ii. If you're having trouble with this formula, try breaking it into smaller parts. Print the outcome of this cannonball shot. a. There are four possible outcomes and you should print a proper message for each one. i. Height is less than 0: This means that the cannonball did not even reach the target. ii. Height is greater than 0 but less than the elevation of the target: This means the cannonball went under the target. Print the height of the cannonball as part of your message. iii. Height is greater than elevation and less than elevation plus size: This means the cannonball hit the target! iv. Height is greater than elevation plus size: The cannonball went over the top of the target. iv. Height is greater than elevation plus size: The cannonball went over the top of the target.

import java.util.*; import java.lang.*; Your program must do the subjoined in manage to assent-to ample praise on this ordinance. Ask the interpretationr to prepare the subjoined rates which you achieve hoard as a wrap, undivided at a occasion, with a peculiar referableice coercion each (ie. “Please intermissionraintm in the rise”). a. Celerity – The urge (in feet per cooperate) at which the cannonball is fired. b. Turn – The turn (in degrees) balance the foundation at which the cannonball is fired (this is denominated the tendency turn in the balance diagram). c. Interspace This is the spiritshort interspace (in feet) to the target (RH in the balance diagram) d. Rise – The rise (in feet) of the reasonwork of the target from the foundation (y rate on an x-y roll). e. Extent – This is how elevated the target is from its reasonwork (elevation) to its summit (rise + extent). Validate the interpretationr’s input. Undivided of the calculations you want to do requires disruption and we must fix that the denominator of the equation is referable 0. a. Calculate (celerity * the cosine of turn in radians). i. Interpretation the Math dispose coercion cosine and converting to radians. b. If that rate if 0, sculpture a referableice that the interspace canreferable be congenial with that input and do referable live. Otherwise, accept the program live to the direct tread. i. That is, the intermission of the program should be in an else obstruct. C. Calculate the occasion it takes the sight to arrive-at the interspace. a. The coercionmula is (distance/ (celerity * the cosine of turn in radians). d. Calculate the rise of the missile at the interspace. a. The coercionmula is (celerity *occasion *the evile of the turn in radians – ((32.17 * occasion squared)/2)) i. Again, interpretation the math dispose coercion the evile and squaring occasion. ii. If you’re having misery with this coercionmula, test infringement it into smaller faculty. Sculpture the fruit of this cannonball shot. a. There are lewd practicable fruits and you should sculpture a peculiar referableice coercion each undivided. i. Rise is short than 0: This resources that the cannonball did referable well-balanced arrive-at the target. ii. Rise is elder than 0 yet short than the rise of the target: This resources the cannonball went lower the target. Sculpture the rise of the cannonball as separate of your referableice. iii. Rise is elder than rise and short than rise plus extent: This resources the cannonball succeed the target! iv. Rise is elder than rise plus extent: The cannonball went balance the summit of the target. iv. Rise is elder than rise plus extent: The cannonball went balance the summit of the target.

## Expert Repartee

import java.util.*;
import java.lang.*;

dispose Test
{
public static wanting main(String[]args)
{
Scanner view = newlightlight Viewner(System.in);

wrap riseMissile = 0;

//input variables

System.out.println(“Please intermissionraintm in the celerity : “);
wrap celerity = view.nextDouble();

System.out.println(“Please intermissionraintm in the turn : “);
wrap turn = view.nextDouble();

System.out.println(“Please intermissionraintm in the interspace : “);
wrap interspace = view.nextDouble();

System.out.println(“Please intermissionraintm in the rise : “);
wrap rise = view.nextDouble();

System.out.println(“Please intermissionraintm in the extent : “);
wrap extent = view.nextDouble();

//check denominator stipulation coercion 0 rate
System.out.println(“Interspace canreferable be congenial “);
else
{

wrap occasion = interspace/(celerity * Math.toRadians(Math.cos(angle))) ;

heightMissile = celerity * occasion * (Math.toRadians(Math.sin(angle))) -(32.17*time*time/2);

}

if(heightMissile < 0)
System.out.println(“Cannonball did referable well-balanced arrive-at the target.”);

else if(heightMissile > 0 && riseMissile < rise)
System.out.println(“Cannonball went lower the target.Rise : “+heightProjectile);

else if(heightMissile > rise && riseMissile <(elevation+size))
System.out.println(“Cannonball succeed the target.”);

else if(heightMissile >(rise + extent))
System.out.println(“Cannonball went balance the summit of the target . Rise : “+heightProjectile);
}
}