Question

In: Computer Science

When an object is falling because of gravity, the following formula can be used to determine...

When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period:
d=1/2 gt^2
The variables in the formula are as follows:
d is the distance in meters,
g is 9.8,
t is the amount of time, in seconds, that the object has been falling.
Design a function named calcFallingDistance that accepts an object’s falling time (in seconds) as an argument. The function should return the distance, in meters, that the object has fallen during that time interval.
Design a program that calls the function in a loop that passes the values 1 through 10 as arguments and displays the return value.


Solutions

Expert Solution

Given below is the code in C++:

#include <iostream>
using namespace std;

#define g 9.8

float calcFallingDistance(int t) // Function definition
{
float distance; // distance defined as float as dividing by 2 can give float value
distance = (0.5*g*t*t); // Calculating distance based on the given formula
return distance; // Returning distance
}

int main()
{
for(int i=1;i<=10;i++)
{
cout<<calcFallingDistance(i)<<"\t"; // Function call
}

return 0;
}


Related Solutions

When an object is falling because of gravity, the following formula can be use to determine...
When an object is falling because of gravity, the following formula can be use to determine the distance that object falls in a specific time period: d = 1/2 g t*t The variables in the formula are as follows: d is the distance in meters g is 9.8 t is the amount of time, in seconds that the object has been falling. Design a function called fallingDistance() that accepts an object's falling time (in seconds) as an argument. The function...
PYTHON Falling Distance When an object is falling because of gravity, the following formula can be...
PYTHON Falling Distance When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period: d = ½ gt2 The variables in the formula are as follows: d is the distance in meters g is 9.8 (the gravitational constant) t is the amount of time in seconds the object has been falling Your program will calculate the distance in meters based on the object’s falling distance....
Task 3. Falling distance When an object is falling because of gravity, the following formula can...
Task 3. Falling distance When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period: d=(1/2)gt2 The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the amount of time, in seconds, that the object has been falling. 3.1.     Create a method: FallingDistance Parameters:           t, object’s falling time (in seconds). t may or may not...
Radioactive decay can be used to determine the age of an object. If you know the...
Radioactive decay can be used to determine the age of an object. If you know the number of radioactive nuclei with which an object started, the number of radioactive nuclei currently present, and the half-life of the isotope, you can calculate the time since the object was created. Suppose an object was created with 4.810×109 nuclei of a particular isotope that has a half-life of 1.56×103 yr. At this point in time 9.620×108 nuclei of this particular isotope remain. What...
Compute​ P(X) using the binomial probability formula. Then determine whether the normal distribution can be used...
Compute​ P(X) using the binomial probability formula. Then determine whether the normal distribution can be used to estimate this probability. If​ so, approximate​ P(X) using the normal distribution and compare the result with the exact probability. nequals62​, pequals0.3​, and Xequals8
Compute​ P(X) using the binomial probability formula. Then determine whether the normal distribution can be used...
Compute​ P(X) using the binomial probability formula. Then determine whether the normal distribution can be used to estimate this probability. If​ so, approximate​ P(X) using the normal distribution and compare the result with the exact probability. n=40, p=0.35​, X=20 P (X) = Can the normal distribution be used to approximate this​probability? Approximate​ P(X) using the normal distribution. Use a standard normal distribution table. Select the correct choice below and fill in any answer boxes in your choice. By how much...
Compute​ P(X) using the binomial probability formula. Then determine whether the normal distribution can be used...
Compute​ P(X) using the binomial probability formula. Then determine whether the normal distribution can be used to estimate this probability. If​ so, approximate​ P(X) using the normal distribution and compare the result with the exact probability. n=40, p=0.35​, X=20 P (X) = Can the normal distribution be used to approximate this​ probability? Approximate​ P(X) using the normal distribution. Use a standard normal distribution table. Select the correct choice below and fill in any answer boxes in your choice. By how...
how can object -relational database be used to implement an SDBMS?
how can object -relational database be used to implement an SDBMS?
Which of the following is correct?   A. When marginal product is falling, total product must be...
Which of the following is correct?   A. When marginal product is falling, total product must be falling.    B. All of the other answers are incorrect    C. When marginal product is falling, total product must also be falling.    D. Marginal product rises faster than total product and also falls faster than marginal cost.    E. When total product is rising, both average product and marginal cost must also be rising.
How can you determine the type of charge on an object using an electroscope that has...
How can you determine the type of charge on an object using an electroscope that has a net charge of unknown sign? Explain in connection with Triboelectric Series.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT