Question

In: Computer Science

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

C++ When an object is falling because of gravity, the following formula can be used 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 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. 5 Falling Distance (5 points) Seconds Meters 1.0 4.9 2.0 19.6 3.0 44.1 4.0 78.4 5.0 122.5 6.0 176.4 7.0 240.10000000000002 8.0 313.6 9.0 396.90000000000003 10.0 490.0

Solutions

Expert Solution

// C++ Code:-

#include<iostream>
using namespace std;

// Function to calculate the falling distance using formulat 1/2*g*t*t
double fallingDistance(double t)
{
return 0.5*9.8*t*t;
}

int main()
{
cout<<"Time(Seconds) Falling Distance(Meters)"<<endl;
  
// calling fallingDistance function repetedly in loop for value 1 to 10
// Printing the result in desired format.

for(double i=1.0;i<=10.0;i+=1.0)
{
cout<<i<<" "<<fallingDistance(i)<<endl;
}
return 0;
}


Related Solutions

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...
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....
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...
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...
Can you answer the following showing working and formula used. The length of a screw manufactured...
Can you answer the following showing working and formula used. The length of a screw manufactured by a company is normally distributed with mean 2.5cm and a standard deviation 0.1cm. Specifications call for the lengths to range from 2.4cm to 2.6 cm. a, What proportion of parts will be greater than 2.65cm? b, What length is exceeded by 10% of the parts? c, What percentage of parts will not meet the specification? d, If you randomly pick three of those...
how can object -relational database be used to implement an SDBMS?
how can object -relational database be used to implement an SDBMS?
Consider the following propositional formula: (((A ^ B) -> C) ^ ((A ^ C) -> D))...
Consider the following propositional formula: (((A ^ B) -> C) ^ ((A ^ C) -> D)) -> ((A ^ B) -> D) Perform the following tasks for this formula: Convert this formula into CNF form and write a numbered list of all clauses obtained from this formula.
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.
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...
1) Write a program in C++ sin(x) can be approximately calculated using the following formula, where...
1) Write a program in C++ sin(x) can be approximately calculated using the following formula, where n! is factorial(n) – for example 3!=3*2*1 = 6 (the function in previous problem). The more terms we use in the series, the higher will be accuracy of the calculations. By using infinite terms in the series we will have the exact value. Hint 1: For n! simply use (copy and paste) the factorialFunc(n)from previous problem. Hint 2: This problems is similar to the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT