//Castulo Jaosn Quintero CSC5 Chapter 6, Pg. 370, #5
//
/**************************************************************************
*
* Calculate Falling Distance
* ________________________________________________________________________
* This program receives an argument from the loop to calculate
* how far the an item has fallen in meters within a set amount
* of seconds.
*
* Computation is based on formula:
* distance = 0.5 * (9.8 * (t * t))
* ________________________________________________________________________
* INPUT
* N/A
*
* OUTPUT
* seconds : The amount of seconds that have passed
* while the object was falling.
* distanceFall : The distance in meters the object has fallen.
*
*************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
// Prototypes
float fallingDistance(float);
// Main function
int main()
{
// Variables
float distanceFall;
float seconds;
// Loop and Output
for (int i = 1; i <= 10; i++)
{
seconds = i;
distanceFall = fallingDistance(seconds);
cout << "The distance the objest has fallen in " << seconds
<< " second(s) is " << distanceFall << " meters\n";
}
return 0;
}
// Value returning function and calculations
float fallingDistance (float time)
{
return 0.5 * (9.8 * (time * time));
}