Question

In a given polynomial, enter the coefficient 'cf' as a parameter and create the member function...

In a given polynomial, enter the coefficient 'cf' as a parameter and create the member function 'numofCoeff', which returns the number of terms with the same coefficient as 'cf'.

class Polynomial; // 전방 선언

    class Term {

    friend Polynomial; // Polynomial 클래스에서 접근 가능

    private:

         float coef;  

        int exp;

    };

class Polynomial {

    private:   

Term *termArray;

int capacity;

int terms;

public:

....

}

int Polynomial:numofCoeff(float cf)

Homework Answers

Answer #1

CODE:

int Polynomial:numofCoeff(float cf)

{

    int count = 0;

    //Iterate through all the terms

    for(int i = 0;i < terms;++i)

    {

        //For each term check the coefficient against the param

        if(termArray[i].coef == cf)

        {

            ++count;

        }

    }

    return count;

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The class Term encapsulates the coefficient and exponent of a single term. Exponents are limited in...
The class Term encapsulates the coefficient and exponent of a single term. Exponents are limited in range from 0 to 99. public class Term : IComparable { private double coefficient; private integer exponent; // Creates a term with the given coefficient and exponent public Term (double coefficient, integer exponent) { … } // Evaluates the current term at x public double Evaluate (double x) { … } // Returns -1, 0, or 1 if the exponent of the current term...
Python 3 Conversion and exception handling Create a function that asks the user to enter a...
Python 3 Conversion and exception handling Create a function that asks the user to enter a number and returns the number. * function name: get_int * parameters: prompt (string) * returns: int * operation: Use the "prompt" parameter as the parameter to an input() call in order to ask the user for a number. Convert the number to a int using the int() function and return this number from the function. but - If the user enters something that cannot...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
Objectives:The focus of this assignment is to create and use a recursive method given a moderately...
Objectives:The focus of this assignment is to create and use a recursive method given a moderately difficult problem. Program Description: This project will alter the EmployeeManager to add a search feature, allowing the user to find an Employee by a substring of their name. This will be done by implementing the Rabin-Karp algorithm. A total of seven classes are required. Employee (From previous assignment) HourlyEmployee (From previous assignment) SalaryEmployee (From previous assignment) CommissionEmployee (From previous assignment) EmployeeManager (Altered from previous...
import java.util.Scanner; public class InRange { private int min; private int max; public InRange(int initialMin, int...
import java.util.Scanner; public class InRange { private int min; private int max; public InRange(int initialMin, int initialMax) { min = initialMin; max = initialMax; } // You need to write two instance methods: // 1.) A method named inRange, which takes an int. // This returns true if the int is within the given range // (inclusive), else false. // // 2.) A method named outOfRange which takes an int. // This returns false if the int is within the...
Task 6: Create a function in Java that counts the number of even digits in a...
Task 6: Create a function in Java that counts the number of even digits in a positive integer. public static int countEvenDigits(int a); // Ex, countEvenDigits(1234) => 2 Task 7: Create a generic function that returns digits in a given range. The ones place corresponds to power 0, the tens place corresponds to power 1, the hundreds place corresponds to power 2, and so on. Think 10^3 => 1000 => thousands place. (Do not use exponents in your code.) //...
In this assignment, you’ll make an inventory system for a store’s items, including produce and books....
In this assignment, you’ll make an inventory system for a store’s items, including produce and books. The starter program is an inventory system for only produce. 1. Include the price of an item by adding to the Item class the protected data member int priceInDollars that stores the price in dollars of an individual item. Write a public function SetPrice with a single int parameter prcInDllrs and returns nothing. SetPrice assigns the value of prcInDllrs to priceInDollars. Modify the AddItemToInventory...
Create a class StacktwoPopArr using Arrays, Change the pop function so that two elements get popped...
Create a class StacktwoPopArr using Arrays, Change the pop function so that two elements get popped everytime instead of the one. If there is only one element in the stack, just pop the one element and report that the stack is now empty. If stack is empty, it should just report that stack is empty. All other functions for StackArray remain the same. using java StackArray.java: public class StackArray {       private final int size = 20; //Size of...
Complete the // TODO sections in the EasyRental class. Create a method that implements an iterative...
Complete the // TODO sections in the EasyRental class. Create a method that implements an iterative sort that sorts the vehicle rentals by color in ascending order (smallest to largest) Create a method to binary search for a vehicle based on a color, that should return the index where the vehicle was found or -1 You are comparing Strings in an object not integers. Ex. If the input is: brown red white blue black -1 the output is: Enter the...
Determine how all of your classes are related, and create a complete UML class diagram representing...
Determine how all of your classes are related, and create a complete UML class diagram representing your class structure. Don't forget to include the appropriate relationships between the classes. GameDriver import java.util.Scanner; public class GameDriver { Scanner in = new Scanner(System.in); public static void main(String[] args) { Move move1 = new Move("Vine Whip", "Grass", 45, 1.0f); Move move2 = new Move("Tackle", "Normal", 50, 1.0f); Move move3 = new Move("Take Down", "Normal", 90, 0.85f); Move move4 = new Move("Razor Leaf", "Grass",...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT