I am trying to make a program that will allow me to manipulate multi-variable polynomials. I want to be able to deal with expressions that have more than one variable, and each with its own exponent. For example, one example of a polynomial object will contain information from 5x^2*y^3.
I want to store this polynomial's information in instance variables: an int for the coefficient, a String[] for the variables, and an int[] for the exponents for each variable.
How would I go about linking the two arrays to relate each variable to it's own exponent? I do not want to just have the variable and it's exponent in the same index of different arrays. I would like to know how to have a more guaranteed way that the data will be properly handled.
First create a POJO class to store polynomial variables in the fields coefficient, variable, exponent.
Then call them from another class;
Here is the POJO class, I call it Element;
And the Test Code is as follows;
The output is as follows;