Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please code in Java and follow the steps Polynomial Implementation (ADT Implementation Using Linked Structures) Summary Implement the Polynomial interface using a private linked Node

please code in Java and follow the steps
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Polynomial Implementation (ADT Implementation Using Linked Structures) Summary Implement the Polynomial interface using a private linked Node class. (NOT a Einkedtist or any other data structure.) Your implementation must provide suitable code for each of the operations in that interface. It must also have a zero-arguments constructor. (The default constructor may be suitable.) Details I have provided you with an interface for a Polynomial data type. It contains only some basic methods (no methods for mathematical operations on full Polynomials, for example). I have also provided you with a sample client program. You SHOULD NOT modify those files. I assume you are familiar with polynomials, but I have provided some information in the Polynomial javadoc. You must use a private Node class in your implementation. You are not allowed to make use of any reference types that you have not defined yourself. I recommend that you keep the Nodes in the order they get printed in. Thus the Polynomial 0.2x5+x2+3.5x+2.0 would be kept as the linked structure: head {]{0.25]{1.02]{3.511{2.00/] where the *s represent references and the / represents a nu11 reference. That's a recommendation, which means you don't have to do it that way!. You might not need to add a constructor to your class, but if you do make sure you have a no-arguments constructor. The method getDegree should be very easy. The methods evaluateAt and getcoefficient should be pretty easy. The add and tostring methods will be somewhat harder. I recommend you start with a partial implementation of add that just places the given term at the front of the list of terms. Then move on to tostring and get that printing each term the way you want it printed. The output will not be entirely the way it needs to be, but each term printed should be OK. For example: you might see x2+3.0x5+5.1x3+0.2x5+x2+3.5x+2.0 After you've got tostring working as you want, you can then move on to making add behave properly. BONUS POINTS for replacing + signs with - signs and integer coefficients without decimal points. For example, printing 0.2x5+x2+3.5x+2.0 as 0.2x5+x23.5x+2 Be careful that you don't mess up the first term, which has no + sign in front of it to be changed. Thus we should not see 0.2x5+3.5x as * An interface with some basic polynomial methods. A polynomial is the sum of * several terms, each of which is a multiple of a power of x. The powers are * non-negative integers. The multiple is double, and terms multiplied by zero * are ignored. The multiplier for a term is called its coefficient. * For example: * pre> * 0.2x5+1x2+3.5x1+2x0 * pre > has four (non-zero) terms, as follows: * >0.2 td >5 tr > * tr align= ' center' >td>1,0td>2/td>/tr * = ' center ' >td>3.5td>1* >2.00 tables * p * Terms are printed in order from highest power to lowest power. Each (non- * zero) term shows the coefficient and the power of x, except for terms with a * coefficient of one, or a power of one or less. The coefficient one may be * left out. Terms with power one leave the power off, and terms with power zero * leave both the power and the x off. Other powers are preceded with a "hat" * symbol (*, also known as a circumflex). For example, the polynomial above * could be written as t * 0.2x5+x2+3.5x+2.0 code > i bI * Polynomials with no terms are written as zero. * p * The highest power in the polynomial is called the degree of the * polynomial. If there are no terms in the polynomial, then the power is zero. * p> * Polynomials are evaluated by replacing the x with a given value and * calculating the sum. For example, the polynomial above at 2.0 would evaluate * to * * 0.2& times; 2 sup >5+1& times; 22+3.5 times; 21 sup >+2&t =0.2& times; 32+1&t imes; 4+3.5×2+2×1 =6.4+4+7+2=5.4 * * eauthor */ public interface Polynomial f blic interface Polynomial \{ public String tostring(); / * Add another term to this polynomial. If this polynomial already has a * term with the same power, the terms are combined, which might result in * that term being "zeroed out" and removed from the polynomial. * This method returns the polynomial is was called on, allowing the method * to be called repeatedly on one object to add multiple terms. For example, * > poly.add (3,2)add(2,1)add(7,0) code > adds 3x2 sup >+2x+7 to poly code >. * eparam coefficient the coefficient of the term to add * eparam power the power of the term to add * ereturn the same polynomial, as modified by the addition of the term */ public Polynomial add(double coefficient, int power);Not the question youre looking for?Post any question and get expert help quickly.Start learning Chegg Products & ServicesChegg Study HelpCitation GeneratorDigital Access CodesGrammar CheckerMath SolverMobile AppsSolutions ManualPlagiarism CheckerChegg PerksCompanyCompanyAbout CheggChegg For GoodCollege MarketingInvestor RelationsJobsJoin Our Affiliate ProgramMedia CenterSite MapChegg NetworkChegg NetworkBusuuCitation MachineEasyBibMathwayThinkfulCustomer ServiceCustomer ServiceGive Us FeedbackCustomer ServiceManage SubscriptionEducatorsEducatorsAcademic IntegrityHonor ShieldInstitute of Digital Learning 2003-2024 Chegg Inc. All rights reserved.Cookie NoticeYour Privacy ChoicesDo Not Sell My InfoGeneral PoliciesPrivacy Policy (New)Honor CodeIP Rights

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions