Although I think this is an issue with my loops structure/conditions this could also be an issue with how Java does arithmetic. I'm sure this is probably simple but I can't find it right now.
The polynomial object is composed of an array of size 100 which stores the coefficients of a polynomial in index locations corresponding to the power of each respective term. The purpose of this code is to create a new polynomial object which is the result of multiplying two polynomials.
I'm pretty sure that the loop is not ending but I'm not sure why. The initial S.o.ps of i+j values are what I expect but then they go into enormous negative numbers and I have no idea why.
By the way,public Polynomial mult(Polynomial p) throws ExponentOutOfRangeException { Polynomial multiPolynomial = new Polynomial(); //Start testcode System.out.print("this polynomial "); this.displayPolynomial(); System.out.print("p polynomial "); p.displayPolynomial(); //End testcode for(int i = 0; i < 99; i++) { for(int j = 0; j < 99; i++) { if((i+j) < MAX) { multiPolynomial.polyArr[i + j] = multiPolynomial.polyArr[i + j] + (this.polyArr[i] * p.polyArr[j]); } } } // Multiplies polynomial p to this polynomial without modifying this // polynomial and returns the result. // Precondition: None. // Postcondition: The returned polynomial is the product of this // and p. Both this and p are unchanged. // Throws: ExponentOutOfRangeException if exponent is out of range. return multiPolynomial; }