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 java program to reads ten values from user

Write the java program which reads 10 values from user and store them in 1 daimantion array. your program will ask the user wich operation he wants to perform:

  Write java program to store values retrieved from user-array

Write a Java program named Arrays6_2GF.java Use an array to store values retrieved from user input. The number of integers to be entered (the length of the array )should also be retrieved through user input.

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  An elementary calculation yields the result

An elementary calculation yields the result that theoretically, the probability of turning up 7 when two dice are thrown is 1/6, or .166666. But what if more dice are thrown? If 3 dice are thrown, what is the probability that some 2 of three sum to 7..

  Write java code to read integers from an input file

write java code to read integers from an input file and write only the odd numbers to an output file. the two file names will be provided on the command line as the input file followed by the output file.

  The program reads in names

Write a program and include the following methods. The program reads in names and ages (use 2 parallel arrays, maximum size 50) from a file called Stuff.dat.

  Write a java program to implement the finite field

Write a program called "GF2.java" to implement the finite field GF(p n ) where p is a prime number and n is a positive integer.  You also need to write four methods to realize "+", "-", "´", and "/".

  Write a java application to ask number of assignments

Write a java application that accomplishes the following tasks with built in exception handling: ask the number of homework assignment students have submitted in a semester

  Write a java program using array to auto-grade exams

Write a JAVA program using 2D Array to auto-grade exams. For a class of N students, your program should read letter answers (A, B, C, D) for each student.

  Write an application that uses string method region

Write an application that uses String method region - Matches to compare two strings input by the user. The application should input the number of characters to be compared and the starting index of the comparison.

  Write a java applet for grade of gas in costco gas station

Write a java applet (not a java application program) for costco gas station. The applet will first ask you whether you are a costco customer, then the grade of gas you want to use.

  Sequence of method in vector class

Construct a Vector class implementing a number of vector operations as methods along with a testing program to verify the class is working.

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