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...
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...
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
When an object is placed at the proper distance to the left of a converging lens,...
When an object is placed at the proper distance to the left of a converging lens, the image is focused on a screen 31.0 cmto the right of the lens. A diverging lens is now placed 14.2 cm to the right of the converging lens, and it is found that the screen must be moved 19.5 cm farther to the right to obtain a sharp image. What is the focal length of the diverging lens? ......... cm
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...
Which of the following strategies can be implemented in falling interest rate environment to hedge the...
Which of the following strategies can be implemented in falling interest rate environment to hedge the interest rate risk (select as many as applicable)? Please explain your logic in a concise way. 1. Buy short-term and long-term bonds 2. Sell long term bonds and buy short term 3. Buy long term bonds and sell short term 4. Sell a fixed coupon bond and enter a swap receiver position 5. Buy a fixed coupon bond and enter a swap payer position...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT