Question
Update with FIXME: #include #include #include #include #include using namespace std; const double pi = 3.14159265; const double grav = 9.8; // Earth gravity (m/s^2)
Update with FIXME:
#include
const double pi = 3.14159265; const double grav = 9.8; // Earth gravity (m/s^2)
// Given time, angle, velocity, and gravity // Update x and y values void Trajectory(double t, double a, double v, double& x, double& y) { x = v * t * cos(a); y = v * t * sin(a) - 0.5 * grav * t * t; return; }
// convert degree value to radians double DegToRad(double deg) { return ((deg * pi) / 180.0); }
// print time, x, and y values void PrintUpdate(double t, double x, double y) { cout
int main() { double t = 1.0; // time (s) double fowlY = 0.0; // object's height above ground (m) double fowlAngle = 0.0; // angle of launch of fowl (rad) double fowlVel = 0.0; // velocity of fowl (m/s) double fowlX = 0.0; // object's horiz. dist. from start (m) double fowlLandingX = 0.0; // fowls horiz. dist. from start (m) double swineX = 0.0; // distance to swine (m) double beforeSwineX = 0.0; // distance before swine that is acceptable as a hit (m) bool didHitSwine = false; // did hit the swine? srand(time(0)); swineX = (rand() % 201) + 50; // FIXME Make into a function called PrintIntro cout
// FIXME Make into a function called GetUsrInpt cout > fowlAngle; fowlAngle = DegToRad(fowlAngle); // convert to radians cout > fowlVel; // FIXME Make into a function called LaunchFowl do { PrintUpdate(t, fowlX, fowlY); Trajectory(t, fowlAngle, fowlVel, fowlX, fowlY); t=t+1.0; } while ( fowlY > 0.0 ); // while above ground PrintUpdate(t, fowlX, fowlY);
fowlLandingX = fowlX;
// FIXME Make into a function called DtrmnIfHit beforeSwineX = swineX - 30; if ((fowlLandingX = beforeSwineX)) { cout
return 0; }
Functions - Upset Fowls In this assignment, you'll make a knock-off version of the Angry Birds game. The starter program is a working first draft of the game 1. Correct the first FIXME by moving the intro text to a function named Printlntro Development suggestion: Verify the program has the same behavior before continuing 2. Correct the second FIXME. Notice that the function GetUsrlnpt will need to return two values fowlAngle and fowlVel 3. Correct the third FIXME. Notice that the function LaunchFowl only needs to return the value fowlLandingX, but needs the parameters fowlAngle and fowlVel 4. Correct the fourth FIXME. Notice that the function DtrmnlfHit only needs to return the value didHitSwine, but needs the parameters fowlLandingX and swineX. The main should now look like the following code and the program should behave the same as the first draft: int main) double fow!Angle = 0.0; // angle of launch of fowl (rad) double fowlVe! = 0.0; // velocity of fowl (m/s) double swineX 0.0; // distance to swine (m) double fow! Landingx = 0.0; // fowl's horiz" dist. from start (m) bool didHitSwine false; // did hit the swine ? srand (time (0)) swineX (rand () % 201 ) + 50; PrintIntro GetUsrInpt (swineX, fowlAngle, fowlVel); towl Land ingX LaunchFowl (fowlAngle, fowlVel); didHitSwine Otrmnlfhit (fowl Landingx, swineX)Step 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