#include <iostream> // For cin and cout
#include <iomanip> // For setprecision and formatting
using namespace std;
// Constant for acceleration due to gravity (in meters per second squared)
const double GRAVITY = 9.8;
/**
* @brief Calculates the falling distance of an object given time.
*
* Formula: distance = 0.5 * g * t^2
*
* @param time Time in seconds
* @return Distance in meters
*/
double fallingDistance(double time) {
return 0.5 * GRAVITY * time * time;
}
int main() {
// Set the output to display fixed-point notation with 2 decimal places
cout << fixed << setprecision(2);
cout << "Time (s)\tDistance Fallen (m)\n";
cout << "-------------------------------\n";
// Loop from 1 to 10 seconds
for (int time = 1; time <= 10; ++time) {
double distance = fallingDistance(time);
cout << time << "\t\t" << distance << endl;
}
return 0;
}