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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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