Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (adozenbabydogs):

A for statement isn't running inside of my document

OpenStudy (adozenbabydogs):

package polyDiv; import java.util.*; public class polyDivide { @SuppressWarnings("resource") public static void main(String[] args) { //Initialization and decoration// Scanner in = new Scanner(System.in); float r, b, d, p; int i, j; float[] a, c, n, m; //Introduction// System.out.println("Welcome to the Polynomial Divider!"); System.out.println("Divide things like X^2 and so on!"); System.out.println(""); //loopidy loop// while (true) { System.out.print("Please input the number of the highest exponent: "); i = in.nextInt(); n = new float[i]; m = new float[i]; a = new float[i]; c = new float[i]; for (j = 0; j > i; j++) { System.out.print("Please input a when a is aX^" + (i-j) + ": "); a[i-j] = in.nextFloat(); } for (j = 0; j > i; j++) { System.out.print("Please input c when c is cX^" + (i-j) + ": "); c[i-j] = in.nextFloat(); } } } }

OpenStudy (mathmate):

the second parameter of your for-loops is playing a trick on you. Read up: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html and note the definition: "When the termination expression evaluates to false, the loop terminates." since j=0 to start, j>i is already false, so the loop never got executed.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!