Design a function named "falling distance"

Assignment Help JAVA Programming
Reference no: EM13162931

 Design a function named "fallingDistance" that accepts an objects 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.

 

This is what I have, it returns 10 values but it does not take into account the input

 

public static void main(String[] args) {
         double fallTime;
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Please enter the time, in seconds, for how long the object has fallen:");
            fallTime = keyboard.nextDouble();
        for(int i = 1; i<11; i++)
        {
            DecimalFormat df = new DecimalFormat("#,#,###.00");
           //Print
            System.out.println("The object has fallen " + df.format(fallingDistance(i)) + " meters");
        }
    }
    //Function
      public static double fallingDistance(double fallTime)
      {
          //Formula is d = 1/2gt^2
      double a = 0.5, gravity = 9.8, distance;
     
      distance = (a * gravity) * (Math.pow(fallTime, 2.0));
        return distance;
      }
}

Reference no: EM13162931

Questions Cloud

What type of social influence situation : In what type of social influence situation do we follow direct commands from others?  forming, storming, norming, and performing
Analyze and create unique solutions : The ability to analyze and create unique solutions designed to make decisive and immediate resolutions, which allows for timely completion of tasks
Explain what is the volume of the gas at stp conditions : What is the volume of the gas at STP conditions? b.) What is the molar volume of the gas?
Who remains neutral in conflict : The person who remains neutral in a conflict but renders a binding solution to the conflict is known as a(n). People who score high on the Realistic theme of the Strong Interest Inventory would most likely enjoy a job working as an
Design a function named "falling distance" : Design a function named "fallingDistance" that accepts an objects 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 func..
Mandate of heaven : The Mandate of Heaven- could allow a dynasty to rule forever. blessed moral rulers.  showed it was pleased by creating natural disasters.  was a personal god worshipped by emperors.
What impact will the roche buyout have on genentech : What impact will the Roche buyout have on Genentech? Will it be possible for Roche to own Genentech without destroying its ability to innovate?
Add insert and edit menu options : Add Insert and Edit menu options - Insert will allow the user to insert a new account in a position of his choice
Explain water reacts with ammonium hydroxide : Iron(III) in water reacts with Hydrochloric acid B. Iron(III) in water reacts with Ammonium Hydroxide Then identify the geometry of the iron(III) complex in water and the complex ions produced in the above reactions

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write program in java to calculate interest

Write a program in java to do the following : the following data is stored for each customer in the bank: account number,average balance and number of transaction for each customer it is required to calculate the interest earn

  Program should assign a seat in the first class

If a person enters 1, your program should assign a seat in the first class (rows 1 - 3). If a person enters 2, your program should assign a seat in business class (rows 4 - 7). If a person enters 3, your program should assign a seat in economy class ..

  Write java program to read in sequence of hourly temperature

Write down Java program which reads in sequence of hourly temperature readings over 24-hour period using arrays. Your program must find and show maximum and minimum temperatures.

  Simulate some people catching fish in a lake in java program

In this project, you will simulate some people catching fish in a lake. The purpose of the assignment is to get used to using Arrays as well as getting more experience in having objects interact together.

  Method named isallvowels that returns

Write a method named isAllVowels that returns whether a String consists entirely of vowels (a, e, i, o, or u, case-insensitively). If every character of the String is a vowel, your method should return true. If any character of the String is a non-vo..

  Write java program to evaluate postfix expressions

Write a java program to evaluate postfix expressions containing complex numbers using a stack. This program should contain two classes.

  Write a while loop that lets the user enter a number

1) Write a while loop that lets the user enter a number. The number should then be multiplied by 10, and stored in a variable called product. The loop should then iterate as long as product contains a value less than 100.

  Can linear search algorithm be encoded using recursion

Determine the average amount of time people spend waiting for tables and provide examples from the "real world" of unsorted lists, sorted lists, indexed lists, lists that permit duplicate elements, and lists that do not permit duplicate elements

  Develop a gui based java program

Designing and developing a College Registration program

  Display random numbers to simulate rolling a die

1. Display random numbers to simulate rolling a die2. Create a java program that simulate a casino game. (rollin a die)

  Write a version of sumpairs

Write a version of sumPairs  that sums each component of the pairs separately, returning a pair consisting of the sum of the first components and the sum of the second components. So basically [(3,1)(10,3)] would return (13,4).

  Web engineering principles

web application development, Web Engineering methodology, UML-based Web Engineering (UWE), models to the expansion of web applications, Object Oriented Web Solutions (OOWS),Web Modeling Language (WebML) methodology, Object-Oriented Hypermedia Design..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd