in java write program that add two Polynomials but the user will enter Polynomials as string
have you started any of this yourserlf?
i solved it without string
can u write the code pls ?
u can help !!
okay so you want an integer lets say.
there is something calling parsing. For an integer you would do Integer.parseInt(String);
but a polynomial like a math function? x^2 + 3x + 10?
the user will enter like that enter first polynomial :x^2+x+1 enter first polynomial :5x^5+x^3+3x^2+10 the result is:5x^5+x^3+4x^2+11
Well you could do something that looks for a character sequence and adds them ie "x^5"
if u can ,write the code pls send it pls
This isn't the right place to ask for someone to do your homework for you. Anyway, if you know this exact format is being used, you can parse all numbers before an x as the coefficient and the number after the ^ as the exponent. When it comes to storing polynomials, there are a few methods that work well. If the exponents are sparse, store polynomials as a pair of coefficient and exponent instead of a list of the coefficient for each exponent. If there are multiple unknowns, a custom data structure may be necessary, depending on the number of values and whether multiple variables may be bundled together. If the roots of the polynomial are being found, they need to be stored as complex numbers for the deflation process. If the polynomial requires simplification, the data structure needs to be sortable.
Join our real-time social learning platform and learn together with your friends!