Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following formula can be used to determine the distance that an object falls

ID: 3536378 • Letter: T

Question

The following formula can be used to determine the distance that an object falls in a specified period of time:

d = (1/2)gt2

d is the distance in meters
g is a constant which is 9.8
t is the time in seconds that the object has been falling.

For this program you need to write a function called fallingDistance which accepts an object's falling time (in seconds) as an argument. The function needs to return the distance (in meters) that the object has fallen during the given time interval. The function should be tested by calling it within a loop that passes the values 10 ~ 20 as arguments to the function. Display the output as a table.

Explanation / Answer

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

const double grav=9.8;
double fallingDistance();

int main()
{
double distance=0;
for (int time=0; time<10; time++)
{
distance =fallingDistance();
cout<<distance<<endl;
}
return 0;
}

double fallingDistance ()
{
double distance=0;
double time=4;
cout<<"please enter the time it took the object to fall:"<<endl;
cout<<"Time"<<endl;
cin>>time;
distance=((.5)*grav)*(pow(time,2));
cout<<"the distance is ";
return distance;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote