A. PROBLEM
The purpose of this project is to equip students with skills of manipulating an array as a data structure
to store and process information, using the C++ object structure construct: struct.
The problem is poised as follows: create a data structure to hold a term of a polynomial and then using
the C++ array data structure design a system to manipulate polynomials by being able to:
1. create a polynomial
2. input a polynomial
3. display a polynomial
4. add/subtract two polynomials
5. multiply two polynomials (NB: multiplying by a polynomial of degree 0 is called scalar
multiplication).
B. METHODOLOGY
The following C++ structure should be used to define a term of a polynomial:
struct term
{
// A polynomial term has two data components:
double coefficient; // The co-efficient of x
int exponent; // The positive integer power of x
};
Students must then write a system of functions together with the corresponding main function that will
allow the user, using a menu system, to:
1. create a polynomial of his/choice. For example, a call like the following should create a polynomial
x of length 6:
term *x = CreatePolynom ial( /* of length */ 6);
where all the coefficients and exponents are initialised to zero.
2. input data into the polynomial of a given length. For example, the following function call should
allow the user to populate his/her polynomial P of length N:
InputPolynomial(P, N);
3. display a polynomial of a given length. For example, the following function call should allow the user
to display his/her polynomial P of length N:
DisplayPolynomial(P, N);
CS 2431 - Prog. Fundamentals Project-01 Due: 1 wk before end of lectures 2007 Page -2/2-
When a polynomial is displayed, terms with zero coefficients must be omitted from the display.
Further, terms with exponents of value 1 should be displayed as: ax, where a is the corresponding
coefficient (and x is understood to be the polynomial variable). Finally, terms with exponents of value
0 should be displayed as just the constant: a. All the other terms should be displayed as: ax^n, where
n is the power of x (x^n means x to the power n).
4. add any two given polynomials. For example, the following function call should allow the user to add
two polynomials: P1 of length N1 and P2 and length N2 and the result being a new polynomial, P:
P = add(P1, N1, /* with */ P2, N2);
Step 4 should be similar when one is subtracting or multiplying any two given polynomials.
NB: Students who could attempt and get right the synthetic division of polynomials will get a bonus
mark of 50 points more

.

I have been given this problem but i have no idea where to start. can you help me get started.......

Recommended Answers

All 4 Replies

Welcome aboard:
1. You could start off by declaring a few variables that you'll need.
2. You could set up some type of a loop to return greater common divisor of two long integers.
3. You then set up size for array.
4. You may create a dynamic array, assign address data.
5. Prompt the user for desired operation and then for the values.
6.You can then store the input to linked list.
7.Then determines the sign of the coefficients..ex:

if(sign=='-')                
{
do something
}

Please give it a shot and see how much of the code you can come up with on your own and then we'll try to assist you. Again, welcome aboard and hope you enjoy it here.

>>i have no idea where to start
Start here:

int main()
{
    // your code goes here
}

You might research some of these google links

struct Polynomial {

some declarations.........

}; 

maybe?

ooops... minus the code brackets..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.