- Details
- Parent Category: Programming Assignments' Solutions

# We Helped With This C# Programming Homework: Have A Similar One?

Category | Programming |
---|---|

Subject | C# |

Difficulty | College |

Status | Solved |

More Info | C# Homework Help |

## Short Assignment Requirements

## Assignment Description

**Chapter 6
Test – Using methods in C# **

Create a class Polynomial, with fields that hold a :

- a number representing the degree

- an array holding the coefficients;

Ex: 2x^{3} + 5x^{2} – 3x +
5

Will be saved in the a boject as IntDegree = 3 //highest exponent is 3

InCoefficient[0]
= 5 //the coefficient for x^{0} is 5

InCoefficient[1]
= -3 //the coefficient for x^{1} is -3 InCoefficient[2]
= 5 //the coefficient for x^{2} is 5

InCoefficient[3]
= 2 //the coefficient for x^{3} is 2

Your class will:

a) Create 2 properties for the fields: IntDegree and IntCoefficient (this last oen is an array)

b) Is your option if you set a limit to the degree or accept any degree;

c) Create 3 constructors:

o one takes no parameter. Will create the polynomial “0”

o one takes only 1 parameter, the degree. Ex Polynomial(3) will
create the polynomial: “x^{3}”

o one takes 2 parameters: one degree and an array of integers. The length of the array must match with the degree. Ex the degree is 3, then the array must have 4 numbers for the 4 coefficients like in the example above

d) Add
an operator +() that adds 2 polynomials (Ex: (2x^{3} + 5x^{2} – 3x + 5) + (x^{3}) = 3x^{3} + 5x^{2} – 3x + 5)

e) Create a ToString() method that returns a string that represents
the polynomial. Ex: x^{3} + 1 will be returned as “x^3 + 1”

f) Implement the IComparable interface, so that you can use the
Array.Sort() method on polynomials (use the following condition: a polynomial
is bigger than another polynomial if the degree is higher than the degree of
the 2^{nd} polynomial)

Hint: The polynomial “x^{3}” will be stored as
follows:

IntDegree = 3

InCoefficient[0] = 0 //the coefficient for x^{0} is 0

InCoefficient[1]
= 0 //the coefficient for x^{1} is 0 InCoefficient[2] = 0 //the
coefficient for x^{2} is 0

InCoefficient[3]
= 1 //the coefficient for x^{3} is 1

### Testing your data

** **

Create your own code to test the problem above.

The entire program will be saved as PolynomialDemo.cs.