import java.util.Scanner;
public class Homework5
{
public static void main(String[] agrs)
{
double g = 9.8;
int t;
System.out.println("The output is");
for(t = 1; t<=10; t++)
{
fallingDistance(.5*g*t*t);
}
}
public static void fallingDistance(double distance)
{
System.out.println("The distance for " + t + "seconds is " + distance);
}
}
How would I be able to use the variable "t" used in the for loop, to be accessable outside of it, as well as in the fallingDistance method? Thanks!
Comments
Post a Comment