Question: C++ beginner level please You can use physics to calculate how far a projectile will travel. When calculating projectile motion, it is necessary to separate




C++ beginner level please
You can use physics to calculate how far a projectile will travel. When calculating projectile motion, it is necessary to separate the horizontal and vertical components of the motion. This is because the force of gravity only acts on the projectile in the vertical direction, and the horizontal component of the trajectory's velocity remains uniform.[1] Here's an example: Imagine that you fire a cannonball at an angle, as shown in the preceding figure. Given the initial speed of the cannonball and the angle at which it was shot, can you determine how far it will travel? In physics, assuming a flat Earth with a uniform gravity field, and no air resistance, a projectile launched with specific initial conditions will have a predictable range.. This assumption, a.k.a., Ideal projectile motion, simplifies the mathematics and is a close approximation of actual projectile motion in cases where the distances travelled are small [2]. Assuming the projectile is launched from the ground, the ideal project motion formula can be used. The distance to the landing point of a projectile, launched at an angle (in radians) with an initial velocity of velocity (in feet per second), ignoring air resistance, is given by the formula distance=32.2velocityvelocitysin(2angle) Program Assignment: You are to create a game where given the distance to a target, the user is given up to 5 changes to quess a velocity and angle to try to hit the target. If the projectile comes within 0.1% of the distance to the target, the user wins the game. If the projectile doesn't come close enough, the user is told how far off the projectile is and is allowed to try again. Each of the formulas in this problem should be implemented as a C++ value-returning function. Suggestions/hints: Consider the following pseudocode and functions to start: - Ask the user to first enters the distance to target. - Function: GetTargetDistance (...); - The user then enters the angle and velocity for lunching a projectile. GetLauncherAngle (...) ; DegreestoRadians ( ...) ; GetMissileVelocity (...) ; - Determine if the projectile comes within 0.1% of the distance to the target. If so, then the user wins the game. If the projectile doesn't come close enough, the user is told how far off the projectile is and is allowed to try again. - CalcWinningRange ( ... ) ; - CalcMissileDistance ( ... ) - Printsummary ( ...) ; - If there isn't a winning input after five tries, then the user loses the game. DegreesToRadians( ...) To simplify input for the user, your program should allow the angle to be input in degrees. The formula for converting degrees to radians is radians=degrees3.14159265/180.0 Output Example:See end of document for more examples The distance to the target (in feet) must be > zero. Enter target distance: 62.9 The launcher angle (in degrees) must be in-between zero and ninety. Enter launcher angle: 45 The missile velocity (in feet per second) must be greater than zero. Enter missile velocity: 45 Shot Number: 1 Target Distance: 62.9 Launcher Angle: 45 Missile Velocity: 45 Missile Distance: 62.8882 The missile landed 0.0118027 feet short of the target. Hit! You win the game! Submissions: - Source code with pseudocode as comments The distance to the target (in feet) must be > zero. Enter target distance: 62.9 The launcher angle (in degrees) must be in-between zero and ninety. Enter launcher angle: 45 The missile velocity (in feet per second) must be greater than zero. Enter missile velocity: 45 Shot Number: 1 Target Distance: 62.9 Launcher Angle: 45 Missile Velocity: 45 Missile Distance: 62.8882 The missile landed 0.0118027 feet short of the target. Hit! You win the game! The distance to the target (in feet) must be > zero. Enter target distance: 62 The launcher angle (in degrees) must be in-between zero and ninety. Enter launcher angle: 76 The missile velocity (in feet per second) must be greater than zero. Enter missile velocity: 2 The missile velocity (in feet per second) must be greater than zero. Enter missile velocity: 23 Shot Number: 1 Target Distance: 62 Launcher Angle: 76 Missile Velocity: 23 Missile Distance: 7.71275 The missile landed 54.2873 feet short of the target. // Enter tries for shots 24 The launcher angle (in degrees) must be in-between zero and ninety. Enter launcher angle: 35 The missile velocity (in feet per second) must be greater than zero. Enter missile velocity: 75 Shot Number: 5 Target Distance: 62 Launcher Angle: 35 Missile Velocity: 75 Missile Distance: 164.154 The missile landed 102.154 feet past the target. Game Over. Play again. main.cpp Load default template... 123456789#include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
