Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have to write a C++ code to compute Horner\'s algorithm, given aset list of ch

ID: 3616238 • Letter: I

Question

I have to write a C++ code to compute Horner's algorithm, given aset list of choices. First, here's the layout:

-Output a set of options :
0. Quit
1. Set scientific format
2. Set fixed format
3. Evaluate polynom

-Selecting "0" will terminate the program immediately
-Selecting "1" will set all numbers to scientific format (using theflag ios::scientific and the cout.setf function)
-Selecting "2" will set all numbers to fixed format (the flagios::fixed and the cout.setf function)
-Selecting "3" will continue with the algorithm, prompting for:
     -value of x
     -termination value
     -the coefficients (in decreasing degree)and separated by spaces
-Result will display x value (inputted from about) and f(x) value(solution)
-Any selection other than the ones listed above must display"‘?’ is the incorrect choice"
-Loop to the beginning.

Here's my attempt at the solution code:
#include<iostream>
using namespace std;

int main (void)
{

    int n, x, a;

       cout << "0. Quit "
         << "1. Setscientific format "
         << "2. Setfixed format "
         << "3.Evaluate polynom ";

    cin >> n;
    do {
        if (n = 1) {
           cout.setf(ios::scientific);}
        else if (n = 2) {
           cout.setf(ios::fixed);}
        else if (n = 3){
           //i think there should be a loop in here to be able to computeprogressive values of the polynomial
           cout << "Enter x : " endl;
           cin >> x;
           cout << "Enter termination value : " endl;
           cin >> a;
           cout << "Enter space separated coefficients (higher degreefirst) followed by by value" << t << endl;
           cin >> //not sure how to format the input of thecoefficients
           //The algorithm works as follows:
           //1. Define sum := 0
           //2. sum = sum * x + a, for each coefficient a in the polynomial,in decreasing degree
           //order, where x is the numeric value at which the polynomial is tobe evaluated.
           //3. After the last term (degree zero) is handled, sum will be thevalue of the polynomial.
        }
        else if (n != 0&& n != 1 && n!= 2 && n!= 3) {
           cout << 'n' << "is the incorrect choice";}
        while (n != 0);
        return 0;
        }

I will rate veryyy well because this stuff is about to make my headexplode!

Explanation / Answer

please rate - ALL answers - thanks #include using namespace std; int main () {     int n, x, degree,i;      double a,t,sum=0;        cout