Can someone help em out with this:
Im suppose to do this:
http://www.ise.ufl.edu/cgs2421/cpp/files/projects/pro2.pdf
I gotta use loops to solve the horner algorythm
This is whta i have but is not working
#include <iostream>
using namespace std;
int main (void)
{// VARIABLE DECLARATIONS:
double choice;
// EXECUTABLE CODE:
cout << "CGS 2421 Polynom" << endl;
cout << "This program evaluates the value of an arbitrary polynom" << endl;
cout << "at a given point. x is input, and f(x) is the output " <<endl;
cout << endl;
do {
// present menu of options
cout << "0. Quit" << endl;
cout << "1. Set scientific format" << endl;
cout << "2. Set fixed format" << endl;
cout << "3. Evaluate polynom" << endl;
cout << endl;
cout << "Enter your choice : ";
cin >> choice;
if (choice < 0) {
cout << "'"<< choice <<"'"" is the incorrect choice" << endl;
}
else if (choice > 3) {
cout << "'"<< choice <<"'"" is the incorrect choice" << endl;
}
if (choice == 1) {
cout.setf (ios::scientific);
}
if (choice == 2) {
cout.setf (ios::fixed);
}
if (choice == 3) {
double x;
cout << "Enter x : ";
cin >> x;
double term;
cout << "Enter termination value : ";
cin >> term;
cout << "Enter space separated coefficients (higher degree first) followed by value " << term << " : " << endl;
double a;
double sum=0.0, num;
cin >> a >> term;
num = a;
while (a != term) {
sum+=sum*x+a;
if (a > num) {num = a;}
}
cout << "x=" << x << "; " << "f(x)=" << sum << endl;
}
}while (choice != 0);
return 0;
}
I'm not sure what is wrong
ty