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

In this assignment, you are going to turn in a single cpp file. Write a function

ID: 3848706 • Letter: I

Question

In this assignment, you are going to turn in a single cpp file. Write a function that takes inputs int a. int b. and int c.. mid double returns the value of ax^2 + bx + c. (Think of the most appropriate return data type.) Then the main function is going to input a quadratic polynomial, say f(x), and then the polynomial at a certain point. Below is what needs to be seen on the screen. Ill the first line of the screen, print "Input the coefficient (integers) of the quadratic polynomial f. Then the user is going to input three integers, say a. b. c. In the next line, print "The quadratic polynomial is f(x) = ax * x + bx + c". In the next line, print "Enter a point (double) z", followed by a user-input do Print "f(z) = XXX". where XXX is the value of f(z) (z was the double defined as above).

Explanation / Answer

Here is the code for the question along with sample output . Please don't forget to rate the answer if it helpd. Thank you very much.

#include <iostream>
using namespace std;

//evaluates a polynomial ax^2 + bx + c at the point x and returns the results
double evaluatePolynomial(int a, int b, int c, double x)
{
double value = 0;
value += a * x * x;
value += b * x;
value += c;

return value;
}

void display(int a, int b, int c)
{
cout << a << "x*x ";
if(b < 0) //if b is -ve show minus sign
cout << " - " << -b << "x ";
else
cout << " + " << b << "x ";

if(c < 0) //if c is -ve show minus sign
cout << " - " << -c ;
else
cout << " + " << c ;

}
int main()
{
int a, b, c;
double z;

cout << "Input the coeffient (integers) of the quadratic polynomial f: ";
cin >> a >> b >> c;

cout << "The quadratic polynomial is ";
display(a, b, c);
cout << endl;

cout << "Enter a point (double) z: ";
cin >> z;

cout << "f(z) = " << evaluatePolynomial(a, b, c, z) << endl;
}

output


Input the coeffient (integers) of the quadratic polynomial f: 3 4 2
The quadratic polynomial is 3x*x + 4x + 2
Enter a point (double) z: 3
f(z) = 41

Input the coeffient (integers) of the quadratic polynomial f: 3 -2 -7
The quadratic polynomial is 3x*x - 2x - 7
Enter a point (double) z: 2
f(z) = 1