0

Here is my code:

```
#include "Poly.h"
int main(){
Poly p;
int degree = p.degree();
cout << degree << endl;
int coefficient = p.coefficient(5);
return 0;
}
```

```
#include<iostream>
using namespace std;
class Poly{
public:
Poly(); //constructor
int degree(); //Returns the degree of the polynomial
int coefficient(int); //Returns the coefficient of the x term
int changeCoefficient(int, int); //Replaces the coefficient of the x term
void returnPoly(); //Prints out Poly
private:
int power;
int newCoefficient;
int poly[10];
};
```

```
#include "Poly.h"
int poly[10] = {4, 5, 9, 4, 3, 3, 1, 2, 7, 1};
Poly::Poly(){
//Empty constructor
}//end Poly
int Poly::degree(){
return poly[2];
} //end degree
int Poly::coefficient(int power){
for(int i = 0; i < 10; i++){
i++; //increment i to skip over coefficient
if(poly[i] == power){
return poly[i - 1];
}
}
}//end coefficient
int Poly::changeCoefficient(int newCoefficient, int power){
for(int j = 0; j < 10; j++){
j++;//increment j to skip over coefficient
if(poly[j] == power){
poly[j-1] = newCoefficient;
}
}
}//end changeCoefficient
```

When I run the code I get the main returning a int of 134514845, not 5 like I want it to. Why is that and how can I fix that? Thanks,