The following formula can be used to determine an object falls due to gravity in
ID: 3715717 • Letter: T
Question
The following formula can be used to determine an object falls due to gravity in a specific period of time. d = (1/2)GT2 The variables in the formula are as follows: d is the distance in meters g is 9.8 t is the time is seconds that the object has been falling Write a program in C++ that accepts an objects falling time in seconds. The program should include the use of at least one function call. The program should include a looping sequences that permits the entry of multiple inputs values. The program should contain a looping sequence that prints 10 distances from the initial number of seconds entered.
Explanation / Answer
SOurceCode:
#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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.