C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
bartleby

Videos

Textbook Question
Book Icon
Chapter 3.4, Problem 7E

(General math) a. Write, compile, and run a C++ program to compute and display the value of the second-order polynomial a x 2   +   b x   +   c for any user-entered values of the coefficients a, b, c, and the variable x. Have your program display a message to inform users what the program does, and then display suitable prompts to alert users to enter the data. (Hint: Use a prompt such as Enter the coefficient of the x-squared term:.)

b. Check the result of your program written for Exercise 7a by using the following test data:

T e s t   d a t a   s e t   1 :   a   =   0 ,   b   =   0 ,   c   =   22 ,   x   =   56 T e s t   d a t a   s e t   2 :   a   =   0 ,   b   =   22 ,   c   =   0 ,   x   =   2 T e s t   d a t a   s e t   3 :   a   =   22 ,   b   =   0 ,   c   =   0 ,   x   =   2 T e s t   d a t a   s e t   4 :   a   =   2 ,   b   =   4 ,   c   =   5 ,   x   =   2

After finishing your verification, use your program to complete the following chartChapter 3.4, Problem 7E, (General math) a. Write, compile, and run a C++ program to compute and display the value of the

a.

Expert Solution
Check Mark
Program Plan Intro

Program plan:

  1. The variable a, b and c of type float is used to accept the coefficient of second order polynomial.
  2. The variable x of type float is used to accept the value of x of second order polynomial.
  3. The variable p of type float calculates the value of second order polynomial.

Program description:

The main purpose of the program is to accept the coefficient of x and value of x and then calculate and display the value of second order polynomial.

Explanation of Solution

Program

#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    // declaration of variables
    float a, b, c;
    float x;
    float p;
    // Input values 
    cout<<"Input values to calculate value of the second-order polynomial :: 
	    ax^2 + bx +c";
    cout<<"\nEnter the coefficient of the x-squared term(a) :: ";
    cin>>a;
    cout<<"\nEnter the coefficient of the x term (b) :: ";
    cin>>b;
    cout<<"\nEnter the coefficient of the term (c) :: ";
    cin>>c;
    cout<<"\nEnter the value of x :: ";
    cin>>x;
    // Calculate value of the second-order polynomial
    p = a * x * x + b * x + c ;
    cout<<"\nThe value of the second-order polynomial  is :: "<<p;
    return 0;
}

Explanation:

In the above program a, b and c accepts the coefficient of x for second order polynomial. The variable x accepts the value of x and then second order polynomial is calculated and displayed.

Sample Output:

Enterthecoefficientofthex-squaredterm(a)::0

Enterthecoefficientofthexterm(b)::0

Enterthecoefficientoftheterm(c)::22

Enterthevalueofx::56

Thevalueofthesecond-orderpolynomialis::22

b.

Expert Solution
Check Mark
Program Plan Intro

To check the given program for the test values as follows:

Test data set 1: a = 0, b = 0, c = 22, x = 56

Test data set 2: a = 0, b = 22, c = 0, x = 2

Test data set 3: a = 22, b = 0, c = 0, x = 2

Test data set 4: a = 2, b = 4, c = 5, x = 2

To complete the following chart:

    abcxPolynomial Value
    2.017.0-12.01.3
    3.22.015.02.5
    3.22.015.0-2.5
    -2.010.00.02.0
    -2.010.00.04.0
    -2.010.00.05.0
    -2.010.00.06.0
    5.022.018.08.3
    4.2-16.0-20.0-5.2

Explanation of Solution

Given Program

#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    // declaration of variables
    float a, b, c;
    float x;
    float p;
    // Input values 
    cout<<"Input values to calculate value of the second-order polynomial :: 
	    ax^2 + bx +c";
    cout<<"\nEnter the coefficient of the x-squared term(a) :: ";
    cin>>a;
    cout<<"\nEnter the coefficient of the x term (b) :: ";
    cin>>b;
    cout<<"\nEnter the coefficient of the term (c) :: ";
    cin>>c;
    cout<<"\nEnter the value of x :: ";
    cin>>x;
    // Calculate value of the second-order polynomial
    p = a * x * x + b * x + c ;
    cout<<"\nThe value of the second-order polynomial  is :: "<<p;
    return 0;
}

Explanation:

Test data set 1:

a = 0, b = 0, c = 22, x = 56

Sample Output:

Input values to calculate value of the second-order polynomial :: ax^2 + bx +c

Enterthecoefficientofthex-squaredterm(a)::0

Enterthecoefficientofthexterm(b)::0

Enterthecoefficientoftheterm(c)::22

Enterthevalueofx::56

Thevalueofthesecond-orderpolynomialis:: 22

Test data set 2:

a = 0, b = 22, c = 0, x = 2

Sample Output:

Input values to calculate value of the second-order polynomial :: ax^2 + bx +c

Enter the coefficient of the x-squared term(a) :: 0

Enter the coefficient of the x term (b) :: 22

Enter the coefficient of the term (c) :: 0

Enter the value of x :: 2

The value of the second-order polynomial is :: 44

Test data set 3:

a = 22, b = 0, c = 0, x = 2

Sample Output:

Input values to calculate value of the second-order polynomial :: ax^2 + bx +c

Enter the coefficient of the x-squared term(a) :: 22

Enter the coefficient of the x term (b) :: 0

Enter the coefficient of the term (c) :: 0

Enter the value of x :: 2

The value of the second-order polynomial is :: 88

Test data set 4:

a = 2, b = 4, c = 5, x = 2

Sample Output

Input values to calculate value of the second-order polynomial :: ax^2 + bx +c

Enter the coefficient of the x-squared term(a) :: 2

Enter the coefficient of the x term (b) :: 4

Enter the coefficient of the term (c) :: 5

Enter the value of x :: 2

The value of the second-order polynomial is :: 21

Chart

Following chart displays the polynomial value for different values of a, b, c and x.

    abcxPolynomial Value
    2.017.0-12.01.313.480
    3.22.015.02.540.000
    3.22.015.0-2.530.000
    -2.010.00.02.012.000
    -2.010.00.04.08.000
    -2.010.00.05.00.000
    -2.010.00.06.0-12.000
    5.022.018.08.3545.050
    4.2-16.0-20.0-5.2176.768

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
I need to know about the use and configuration of files and folders, and their attributes in Windows Server 2019.
Southern Airline has 15 daily flights from Miami to New York.  Each flight requires two pilots.  Flights that do not have two pilots are canceled (passengers are transferred to other airlines).  The average profit per flight is $6000.  Because pilots get sick from time to time, the airline is considering a policy of keeping four *reserve pilots on standby to replace sick pilots.  Such pilots would introduce an additional cost of $1800 per reserve pilot (whether they fly or not). The pilots on each flight are distinct and the likelihood of any pilot getting sick is independent of the likelihood of any other pilot getting sick.  Southern believes that the probability of any given pilot getting sick is 0.15.  A) Run a simulation of this situation with at least 1000 iterations and report the following for the present policy (no reserve pilots) and the proposed policy (four reserve pilots): The average daily utilization of the aircraft (percentage of total flights that fly) The…
Why is JAVA OOP is really difficult to study?

Chapter 3 Solutions

C++ for Engineers and Scientists

Ch. 3.1 - (Debug) Determine and correct the errors in the...Ch. 3.1 - Prob. 12ECh. 3.1 - Prob. 13ECh. 3.1 - (General math) The area of an ellipse (see Figure...Ch. 3.1 - Prob. 15ECh. 3.2 - Prob. 1ECh. 3.2 - Prob. 2ECh. 3.2 - (Practice) Write a C++ program that displays the...Ch. 3.2 - Prob. 4ECh. 3.2 - Prob. 5ECh. 3.2 - Prob. 6ECh. 3.2 - Prob. 7ECh. 3.2 - Prob. 8ECh. 3.2 - (Electrical eng.) The combined resistance of three...Ch. 3.2 - Prob. 10ECh. 3.2 - Prob. 11ECh. 3.2 - (Civil eng.) Write a C++ program to calculate and...Ch. 3.3 - Prob. 1ECh. 3.3 - Prob. 2ECh. 3.3 - (Practice) Write C++ statements for the following:...Ch. 3.3 - Prob. 4ECh. 3.3 - (General math) Write, compile, and run a C++...Ch. 3.3 - (General math) If a 20-foot ladder is placed on...Ch. 3.3 - (Physics) The maximum height reached by a ball...Ch. 3.3 - (Transportation) Road construction requires...Ch. 3.3 - Prob. 9ECh. 3.3 - Prob. 10ECh. 3.3 - Prob. 11ECh. 3.3 - Prob. 12ECh. 3.4 - Prob. 1ECh. 3.4 - (Practice) a. Write a C++ program that first...Ch. 3.4 - Prob. 3ECh. 3.4 - Prob. 4ECh. 3.4 - Prob. 5ECh. 3.4 - Prob. 6ECh. 3.4 - (General math) a. Write, compile, and run a C++...Ch. 3.4 - Prob. 8ECh. 3.4 - Prob. 9ECh. 3.4 - (Electrical eng.) For the series circuit shown in...Ch. 3.4 - Prob. 11ECh. 3.4 - Prob. 12ECh. 3.4 - Prob. 13ECh. 3.5 - Prob. 1ECh. 3.5 - Prob. 2ECh. 3.5 - Prob. 3ECh. 3.5 - Prob. 4ECh. 3.5 - Prob. 5ECh. 3.6 - Prob. 1ECh. 3.6 - (General math) The value of p can be approximated...Ch. 3.6 - Prob. 3ECh. 3.6 - (General math) The volume of oil stored in an...Ch. 3.6 - Prob. 5ECh. 3.6 - (General math) The perimeter, approximate surface...Ch. 3.6 - Prob. 7ECh. 3.6 - Prob. 8ECh. 3.6 - Prob. 9ECh. 3 - (General math) a. Write a C++ program to calculate...Ch. 3 - General math) a. Write a C++ program to calculate...Ch. 3 - (General math) Modify the program written for...Ch. 3 - (Biology) The number of bacteria, B, in a culture...Ch. 3 - Prob. 5PPCh. 3 - (Heat transfer) The formula developed in Exercise...Ch. 3 - Prob. 7PPCh. 3 - (Electrical eng.) a. The voltage gain of an...Ch. 3 - (Electrical eng.) a. Write, compile, and run a C++...Ch. 3 - (Electrical eng.) The amplification of electronic...Ch. 3 - (Acoustics) The loudness of a sound is measured in...Ch. 3 - (General math) a. A balance has the following...
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Boolean Algebra - Digital Logic and Logic Families - Industrial Electronics; Author: Ekeeda;https://www.youtube.com/watch?v=u7XnJos-_Hs;License: Standard YouTube License, CC-BY
Boolean Algebra 1 – The Laws of Boolean Algebra; Author: Computer Science;https://www.youtube.com/watch?v=EPJf4owqwdA;License: Standard Youtube License