/*

DistanceCBC.cpp - Calculates distance fallen per second by acceleration due to gravity.  Checks to see if object hits ground.
Program accepts height of bridge and time (in seconds) fallen as input.

*/
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	
	int seconds, i;
	float height, d;
	

//query inputs
	cout << "Please input the time of fall in seconds: " << endl;
	cin >> seconds;
	cout << "Please input the height of the bridge in meters: " << endl;
	cin >> height;
	
//set up tables
	cout << "Time Falling (seconds)     Distance Fallen (meters)" << endl;
	cout << "***************************************************" << endl;

//calculation loop
	i = 0;
	while(i <= seconds)
	{
		d = 0.5 * 9.8 * (i * i);
		cout << setw(5) << i << setw(30) << d << endl;
		if(d > height)
		{
			cout << "Warning - Bad Data:  The distance fallen exceeds the height of the bridge" << endl;
			return 1;
		}
		i++;
	}

return 0;
}

