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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started