Below is my program. I need it to run 1 - 12seconds and the distance in feet. But it only shows the 12th second and distance for the 1st second. I need help to get the full output.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
//Intro Screen - this program requires no input
cout << " I will display a table showing the distance" << endl;
cout << "an object falls in 1 through 12 seconds.\n";
The calculation of distanceFalling should be in the for loop so it picks up each iteration of seconds from 1 to 11. Right now it only gets calculates once when the variable is declared up top. distanceFalling = ((.5 * 32.2) * (seconds * seconds));
If you edit your post, highlight your code and click on the <> button in the Format palette at the right side of the post, it'll format your code for the forum. It makes it easier to read and point out specific line numbers. :)
double accuracy = 0.1; //this is if you want it to record the distance for
//every 10th of a second.
//to do so, instead of seconds++ like below, put
//seconds = seconds + accuracy
for (seconds = 1; seconds < 12; seconds = seconds++)
{
cout << seconds << " " << distanceFalling(seconds)
}