The problem states to write a method named fallingDistance that accepts an object's falling time as an argument. The method should return the distance that the object has fallen during the time interval. Demonstrate the method by calling it in a loop that passes the values 1-10 as arguments and displays the return value......

I got it to compile but get a hole bunch of this:

Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.Double
at java.util.Formatter$FormatSpecifier.failConversion(
at java.util.Formatter$FormatSpecifier.printInteger(
at java.util.Formatter$FormatSpecifier.print(
at java.util.Formatter.format(
at fallingDistances1.fallingDistance(
at fallingDistances1.main(

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

Help what am i doing wrong?

import java.util.*;
import java.text.DecimalFormat;

public class fallingDistances1
	public static void main (String [] args) throws IOException

	// method
	public static void fallingDistance ()
	final double  starting_time = 1.0;
	final double  max_time = 10.0;
	final double  increment = 1.0;
	// variables
	double distance;
	double g = 9.8;
	double t = 0;
	double a = 0.5;
	for (distance = starting_time; distance <= max_time; distance =+ increment)
			//calculate distance
			distance = (a)*(g)*(t*t);
			System.out.printf("%d\t\t%.1f\n",t, distance);	


In your printf statement, you use %d which is used for integers, but you associate with that the variable t, which is a double. The error message is saying that %d cannot be used with a double.

You need to replace the %d with %f to print float numbers.

System.out.printf("%f\t\t%.1f\n",t, distance);

awesome that fixed the error message i got when i ran the program but now it only shows the time as being 0 and the distance being 0....its not calculating hmmmm

haha nevermind wow i feel like an airhead i put distance instead of time in my for loop oops