C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
Question
Book Icon
Chapter 18, Problem 18.11E
Program Plan Intro

Program plan:

  • Define class Polynomial. Inside this class,
    • Include a private data members size of type int and coefs array of type double.
    • Include a default constructor to initialize size to 1 and coefs to 0.
    • Include a parametrized constructor to initialize size and coefsarray to user defined values.
    • Overload arithmetic operators for this class using through friend function.
    • Overload input output operators for this class.
    • Overload relational operator for this class.
  • Define a main function. Inside main function,
    • Define four objects p1, p2, p3 and p4 of Polynomial class.
    • Define an array a and a4 of type double holding coefficients.
    • Use coefficients in array ato initialize polynomial p1 and p2 and array a4 to initialize polynomial p4.
    • Then apply all the overloaded operators on these four objects.

Program Description: The following program will create a Polynomial class to represent the polynomials and include functions for operations on these polynomial like base data types.

Blurred answer
Students have asked these similar questions
(java) The Painting Subclass Write class as follows: The class is named Painting, and it inherits from the Art class. It has a private String member variable named medium It has a default constructor that assigns the values "No name" to name, "No artist" to artist, -1 to year, and "No medium" to the medium variable. This default constructor calls the four-argument constructor. It has a four-argument constructor to assign values to the name, artist, year, and medium variables. It has a getter and settersfor the medium variable. It has a toString() method This class contains no other methods Make sure to include your name, the name of this class, our course number, and the Activity number in a Javadoc comment at the top. Make sure to write a Javadoc comment for each of these methods.
Develop class Polynomial . The internal representation of a Polynomial is an array of terms. Each term contains a coefficient and an exponent—e.g., the term                                                                                                                                                                                        2x4has the coefficient 2 and the exponent 4. Develop a complete class containing proper constructor and destructor functions  as well as set and get functions. The class should also provide the following overloaded operator capabilities:                                        "Overload the subtraction operator ( - ) to subtract two Polynomial s."
Problem (Online Address Book): Using classes, design an online address book to keep track of the names, addresses, phone numbers, and dates of birth of family members, close friends, and certain business associates. Define a class addressType that can store a street address, city, state, and ZIP code. Use the appropriate functions to print and store the address. Also, use constructors to automatically initialize the member variables. Define a class extPersonType using the class personType with following members and methods: firstname, lastname, and accessors and mutators, print to display, and constructors.  Define a class dateType for month, day and year as members with its accessors, mutators, and constructors) Design a class addressType. Add a member variable to this class to classify the person as a family member, friend, or business associate. Also, add a member variable to store the phone number. Add (or override) the functions to print and store the appropriate information.…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning