Well for my class I have to write a program that .....
Develop a program that will:
a.Calculate the integral of a n-order polynomial using Simpsonís rule and rectangle rule, the orders will be positive integers.
b.The user shall input the coefficients to the polynomial
c.The user shall be able to define the order of the polynomial
d.The user will define how many segments will be used to approximate the integral
e.The user will define the bounds of the integral
f.The program should use a menu function that will allow the user to rerun the program after 1 execution.
g.The user shall be able to define which integration technique they want to use (They should also have the option to run both integration techniques in one execution)
h.The area calculated for each segment should be saved to an array that is dynamically allocated.
i.The area array should be outputted to a text file for further review.
j.The output file name should be user defined
k.Upon successful calculation of an integral the program should output the integral solution to the screen.
l.The program should be able to handle incorrect inputs
i.User entering 0, negative number or letters should not cause program to crash
I need help with the polynomial part, I dont know if I am going in the right direction, I have bolded the code that has to do with the entering of the polynomial.
int j=1; //Loop for the menu
int technique; //Integration technique
int order; //Order for the polynomial
int totterms; //Total number of terms in the equation
double a; //left endpoint
double b; //right endpoint
double boundtotal; //endpoint math
double subint; //subintervals
double *ptr, *p;
puts("Welcome to the integration program.");
puts("You can compute an integral using either Simpson's or the Rectangular rule.");
puts("\nEnter the order of the polynomial you wish to integrate.");
totterms= order+1; // +1 Because the order also needs a constant to go along with it at the end.
for(count=totterms;count >=0; count--)
printf("\nEnter the coefficient for the %d power.", count);
puts("\nEnter the left endpoint of the integral.");
puts("\nEnter the right endpoint of the integral.");
puts("\nEnter the number of sub-intervals you want to use.");
puts("To integrate using Simpson's Rule enter 1.");
puts("To integrate using the Rectangular Rule enter 2.");
puts("To integrate using both techniques enter 3.");
if(technique == 1)
else if(technique == 2)
else if(technique == 3)
puts("You did not enter a valid menu option, goodbye.");
puts("To restart the program enter 1.");
puts("To quit the program enter 0.");
double f(double x)