Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

undefined 5.19 LAB^: Falling distance When an object is falling because of gravity, the following formula determines the distance the object falls in a specific

undefinedimage text in transcribedimage text in transcribed

5.19 LAB^: Falling distance When an object is falling because of gravity, the following formula determines the distance the object falls in a specific time period: d = 1/2 gt? Where d = distance in meters, g = gravity and t = time in seconds. Use 9.8 m/s for gravity. Write a method computeFalling Distance() that has one parameter: the falling time (in seconds) of an object. The function returns the distance (in meters) the object has fallen. Input Validation: If the parameter is negative or zero, the function returns 0. Ex: If the method is called with the given arguments, will return the following distances: computeFallingDistance (1) returns 4.9 computeFallingDistance (2) returns 19.6 computeFallingDistance (3) returns 44.1 computeFallingDistance (10) returns 490.0 Next, in main, prompt the user for an integer time. The program should loop from 1 to the user input (inclusive), calling computeFalling Distance for each integer. Ex: If the input is: 3 the output is: Time 1 Distance 4.90 19.60 44.10 2 3 Output the floating-point numbers with 2 digits after the decimal point. Your decimal points should align and the numbers should be right- aligned under Distance (as above). This can be achived as follows: System.out.printf("%8.2f ", yourValue); LAB ACTIVITY 5.19.1: LABA: Falling distance 0/10 LabProgram.java Load default template... 1 import java.util.Scanner; 3 public class LabProgram 4 5 /* Type your method here. */ 6 7 8 public static void main(String[] args) { 9 Scanner scnr = new Scanner(System.in); 19 11 /* Type your code here */ 12 13 14 }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions