Question

In: Computer Science

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 be an integer value!

Return value:         the distance, in meters, that the object has fallen during that time interval

Calculations:          Use Math.Pow() to calculated the square in the formula

3.2.     Demonstrate the method by calling it from a loop that passes the values 1 through 20 as arguments, and displays each returned value.

** JAVA PROGRAM **

Solutions

Expert Solution

Hi,

Please find below code as per your requirement.

Let me know if you have any doubt/concerns in this via comments.

Hope this answer helps you.

Thanks.

/***************JAVA CODE***************/

/**************************************/

public class FallingDistanceCalculator {

        /**
         * This is driver method which test the functionality of fallingDistance method
         * @param args
         */
        public static void main(String[] args) {
                
                //Iterating 20 times and calling fallingDistance method with i as parameter and printing output
                for (int i = 1; i <= 20; i++) {
                        System.out.println("Falling distance "+fallingDistance(i)+ " for falling time "+i+" seconds.");
                }
                
        }
        
        /**
         * This method calculates falling distance in meters for given falling time in seconds
         * @param fallingTime
         * @return
         */
        public static double fallingDistance(double fallingTime) {
                double g= 9.8;
                double half = 0.5; //here 1/2 converted to 0.5
                
                //here we are applying formula d = (1/5) * g * falling time power 2
                double fallingDistanceInMeters = (half * g) * Math.pow(fallingTime, 2);
                return fallingDistanceInMeters;
        }
        
        
}

/*****************Ouput*******************/


Related Solutions

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...
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...
Q. 1: The far distance a person can see an object is at a distance of...
Q. 1: The far distance a person can see an object is at a distance of 50 cm from the eye but she wants to see an object at infinity. What types of lens is required to make her vision correction? Calculate the optical power of her lens. Q 2: The near point a person can see an object is at a distance of 50 cm from the eye but he wants to see object at the least distance of...
Newton's law of gravity was inconsistent with Einstein's special relativity because Question 27 options: the distance,...
Newton's law of gravity was inconsistent with Einstein's special relativity because Question 27 options: the distance, and thus the force, depends on the reference frame chosen time dilation slows the apparent acceleration, reducing the force mass, and thus the force, depends on the reference frame chosen Newton didn't know about Einstein
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.
Collecting money from patients can be a daunting task because many people are not comfortable talking...
Collecting money from patients can be a daunting task because many people are not comfortable talking about money, especially when they know that they have owed the provider for quite some time. It is important to display sensitivity to the situation when attempting to collect the money that is owed to the provider for services that have been rendered. Both your verbal and nonverbal communication must remain at a professional level, even if the patient’s communication does not. Using the...
PROGRAM IN C++ The distance a vehicle travels can be calculated using the following equation: distance...
PROGRAM IN C++ The distance a vehicle travels can be calculated using the following equation: distance = speed * time For example, if a train travels 40 miles per hour for 3 hours, the distance traveled is 120 miles. Write a program that asks the user for the speed of a vehicle (in miles per hour) and how many hours it has traveled. The program should then use a loop to display the distance the vehicle has traveled for each...
A man can cover a distance in 1hr 24min by covering 2/3 of the distance at 4 mph and the rest at 5mph.
A man can cover a distance in 1hr 24min by covering 2/3 of the distance at 4 mph and the rest at 5mph. What is the total distance to be covered?
When an object is placed at a distance greater than the focal length but less than twice the focal length from a convex lense
When an object is placed at a distance greater than the focal length but less than twice the focal length from a convex lense the image is diminished.the image is virtual.All of the other choices are not correct.the image is inverted.the image is formed on the same side as theobject.For an object placed in front of a concave lense,the image is always realthe image may be erect or inverted.the image is formed on the other side of thelense.the image may be...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT