Question: JAVA HELP - Parse a string polynomial similar to : -3x^4 -2x^5 -5 +11x^1 (do not remove the whitespace between each node!) Scanner or String

JAVA HELP - Parse a string polynomial similar to :

"-3x^4 -2x^5 -5 +11x^1" (do not remove the whitespace between each node!)

Scanner or String method should be helpful.

public PolynomialImpl() {

term = new EmptyNode();

}

public PolynomialImpl(String str) {

The last 3 steps should have idea similar to:

int coefficient = Integer.parseInt(a string for coefficient);

int power = Integer.parseInt(a string for power);

term = term.addTerm(coefficient, power);

}

For instance, if the input is:

PolynomialImpl("-3x^4 -2x^5 -5 +11x^1");

the result should be:

term.addTerm(-3, 4);

term.addTerm(-2, 5);

term.addTerm(-5, 0);

term.addTerm(11, 1);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!