Question: Input an integer value altitude and use a loop to write your own graphics program 'fall.cpp' that produces a graphic representation of falling object (e.g.
Input an integer value altitude and use a loop to write your own graphics program 'fall.cpp' that produces a graphic representation of falling object (e.g. circle). An object has initial downward velocity 0. Each second, it's velocity increases by 32 ft/sec. Plot the descent of the falling object. Note that terminal velocity is 174 ft/sec so the object's velocity cannot exceed that speed. This is what I have so far, it runs and compiles, but the output doesn't display the plot descent of the falling object. What do I need to add or fix to make it display the falling object?
/* Program: fall.cpp */ /* This program will plot the descent of the falling object */
#include "ccc_win.h"
int ccc_win_main() { cwin.coord(0, 150, 150, 0);
Point p(50, 100); int altitude = 100; int velocity = 32; // Altitude needs to be equal to or greater than 0 // Loops to produce a graphic representation of a falling object while (altitude >= 0) { altitude -= velocity; velocity += 32; // Velocity cannot exceed 174 ft/sec if (velocity > 174) { velocity = 174; } } p.move(0,(-velocity)); cwin << p; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
