public static void main(String[] args) {
double s = 0; //Position
double v = 100; //Velocity
double g = 9.81; //Gravitational Force
for(double time = 0.01; time < 100; time = time + 0.01){
double DELTA_T = 0.01;
s = s + (v * DELTA_T);
v = v - (g * DELTA_T);
if(time % 1 == 0) { //I want to print this out, but it seems to end the program with no output
System.out.println("Seconds: " + time);
System.out.println("Position: " + s);
System.out.println("Velocity: " + v);
}
}
}
I want to output the calculations when (time % 1 == 0). But when I run this, it doesn't print anything out. When I remove the if statement, and leave in the print statements, it will print.
I was wondering what is wrong with my if statement and how would I go about trying to print "s", "v", and "time" every time (time % 1 == 0)