Question

Using C++ language, write a code to implement the "evaluate function" described below using the given...

Using C++ language, write a code to implement the "evaluate function" described below using the given poly.cpp file and poly.h header file. (ignore the other 3 functions if asked)

poly.cpp file:

Using C++ language, write a code to implement the

poly.h header file:

You are asked to implement four functions for a data structure used to store polynomials. The data structure used for polynomials is a linked list that consists of terms where each term consists of a coefficient, an exponent and a pointer to the next term. A polynomial is represented as a pointer to the first term of the linked list of terms. The terms are listed in the descending order based on their exponent (highest exponent/degree term is listed first). There is only a single term for each exponent. We assume that an empty list indicates a polynomial equal to zero.

Your job is to complete the poly.cpp file to implement the missing four functions declared in poly.h. Do not change poly.h and only change the part ofpoly.cpp that is marked with BEGIN and END.

Implement the required functions as follows:

evaluate: Returns the double value of the first parameter (the TermPtr p) at the value of the second parameter. This polynomial value is simply the calculated result of the polynomial for a particular x value. For example, given the polynomial 2.5x^2 + x - 2, its value at x = 10 is 258 (2.5 times 100 plus 10 minus 2), and its value at 5 is 65.5.

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Using C++ language, write a code to implement the "evaluate function" described below using the given...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • programing in c language Write a program, using the following functions, that reads two polynomials and...

    programing in c language Write a program, using the following functions, that reads two polynomials and prints the polynomials before and after the addition. a) polyRead - Read in a polynomial and convert it to its linked list representation. - Return a pointer to the header node of this polynomial. b) polyWrite - Output a polynomial using a form that clearly displays it. c) polyAdd - Compute c = a + b. Do not change either a or b. where,...

  • Description Create a polynomial class with linked lists and implement some basic functions. Specifications Polynomials are...

    Description Create a polynomial class with linked lists and implement some basic functions. Specifications Polynomials are stored in a linked list of Term objects (two classes: Polynomial and Term). Term objects have two data fields: coefficient and exponent, both positive integers. Polynomial will have some methods that create linked list functionality, but not all list operations are needed; include only those used by this program. Do not use a separate linked list class. The list will be non-circular. Make a...

  • I need help filling in the the code in the methods add, multiply, and evaluate package...

    I need help filling in the the code in the methods add, multiply, and evaluate package poly; import java.io.IOException; import java.util.Scanner; /** * This class implements evaluate, add and multiply for polynomials. * * * */ public class Polynomial {       /**    * Reads a polynomial from an input stream (file or keyboard). The storage format    * of the polynomial is:    * <pre>    * <coeff> <degree>    * <coeff> <degree>    * ...    *...

  • A polynomial p(x) is an expression in variable x which is in the form axn + bxn-1 + …. + jx + k, where a, b, …, j, k are...

    A polynomial p(x) is an expression in variable x which is in the form axn + bxn-1 + …. + jx + k, where a, b, …, j, k are real numbers, and n is a non-negative integer. n is called the degree of polynomial. Every term in a polynomial consists of a coefficient and an exponent. For example, for the first term axn, a is the coefficient and n is the exponent. This assignment is about representing and computing...

  • The language is java if you coukd shiwnstep by step on how to get each section

    the language is java if you coukd shiwnstep by step on how to get each section ebapps/blackboard/execute/content/file?cmd-view&content jid _975287 1&course id:_693311 Lab 3 Directions (linked lists) Program #1 1. Show PolynomialADT interface 2. Create the PolyNodeClass with the following methods: default constructor, . overloaded constructor, copy constructor, setCoefficient, setExponent, setNext, getCoefficient, getExponent, getNext 3. Create the PolynomialDataStrucClass with the following methods: defaut constructor, overloaded constructor, copy constructor, isEmpty. setFirstNode. getfirstNode,addPolyNodeFirst (PolyNode is created and set to the end of polynomial),...

  • currentPtr. Use your code to make a boolean function findAndDelete that is given a pointer to...

    currentPtr. Use your code to make a boolean function findAndDelete that is given a pointer to a linked list and a value, and if the value is in the linked list, it is deleted and the function returns true. If it is not in the list, the function returns false. 8. Expand your menu to test your three new functions. When choosing to test the find or findAndDelete functions, the user will be first asked to enter the value to...

  • Polynomial Using LinkedList class of Java Language Description: Implement a polynomial class using a LinkedList defined...

    Polynomial Using LinkedList class of Java Language Description: Implement a polynomial class using a LinkedList defined in Java (1) Define a polynomial that has the following methods for Polynomial a. public Polynomial() POSTCONDITION: Creates a polynomial represents 0 b. public Polynomial(double a0) POSTCONDITION: Creates a polynomial has a single x^0 term with coefficient a0 c. public Polynomial(Polynomial p) POSTCONDITION: Creates a polynomial is the copy of p d. public void add_to_coef(double amount, int exponent) POSTCONDITION: Adds the given amount to...

  • The polynomial addition C function of Program 2.6 padd is the code when the polynomial is used to...

    The polynomial addition C function of Program 2.6 padd is the code when the polynomial is used to arrange the polynomial in the two arrangement methods of the polynomial described in the text 2.4.2. For the remaining method, when the expression polynomial is arranged by a coefficient, create a polynomial addition C function padd() corresponding to Program 2.6. 66 Arrays And Structures are zero are not displayed. The term with exponent equal to zero does not shouw able since x...

  • in C++ as Exercise P12.14. Write a class Polynomial that stores a polynomial such p(x) =...

    in C++ as Exercise P12.14. Write a class Polynomial that stores a polynomial such p(x) = 5x10 + 9x7-x-10 as a linked list of terms. A term contains the coefficient and the example, you would store p(x) as power of x. For (5,10),(9,7),(-1,1),(一10,0) Supply member functions to add, multiply, and print polynomials. Supply a com- structor that makes a polynomial from a single term. For example, the polynomia; can be constructed as Polynomial p(Term(-10, 0)); p.add (Polynomial(Term(-1, 1))); p.add (Polynomial(Term(9,...

  • For this lab, you must define a class called Polynomial. This class definition must include the f...

    please answer this question in python 3 For this lab, you must define a class called Polynomial. This class definition must include the following methods: ._init_0- the initialiser for the class ._str_0- returns a formatted string representation of a Polynomial object add_term) - adds a new term (coefficient and exponent) to the Polynomial .addo-modifies the existing Polynomial by adding another one to it ._add_0-returns a new Polynomial object that is the sum of two polynomials scale) - scales a Polynomial...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT