I need help with this programming assignment There is code b

I need help with this programming assignment. There is code below. DO NOT CHANGE ANYTHING IN MAIN OR ADD HEADER FILES
New Skills Practiced (Learning Goals)
C++ Programming

Problem solving and debugging.
Functions.

A polynomial of the form ax2 + bx + c is called a quadratic. If the coefficients a, b, and c are known, the quadratic formula can be used to find values (called roots) for x such that

ax2 + bx + c = 0

Computing Roots

Linear Case: If a is equal to 0, then the equation is linear and there is only one real root.
x = -c / b

Quadratic Case: If a is not equal to 0, then the equation is quadratic and can be solved by using the quadratic formula:

b2 - 4ac is called the discriminant and its value can be used to determine if there will be exactly 1 real root, 2 different real roots, or 2 complex roots.

If the discriminant = 0, then there is exactly 1 real root.

If the discriminant > 0, then there are 2 different real roots.

If the discriminant < 0, then there are 2 complex (imaginary) roots.
If there are two complex roots, x1 and x2 are of the form x + yi and x - yi, where


The Program
The file contains the framework of a program designed to read the values of a, b, and c , display the polynomial, use a, b, and c to compute the root(s) of the polynomial and display them until the end of file is encountered.


Requirements

Read through the program. The comments describe what the program is supposed to do. The program will compile, but is missing the body of each function.

Using the function descriptions and sample output below, complete each function.

Create data files to test your program. Each file should consist of several sets of a, b, and c values.

NOTES:

Assumptions about input: (you do not have to test for these conditions)

the data file will exist and all input values will be integers separated by whitespace

each data set will consist of 3 integers that represent a, b, and c (in that order)

the last line in the data file will be terminated with a linefeed (\'\ \')

Program must be designed to run in batch mode (no prompts) via Linux redirection.

Display all floating point numbers with 3 digits to the right of the decimal.

Display equation as described in the documentation for the print_equation function.

If the equation is quadratic and x1 and x2 are the same, display only one value for x.

Each data set will represent the coefficients of a solvable equation (the values for a and b will not simultaneously be 0).

Make sure your program does not display -0.000 as a result. (On our system, 0.0 divided by a negative # will result in -0.0) If the root of an equation is zero, display it as 0.000.

Sample terminal session:
[keys]$ g++ ex08.cpp
[keys]$ more data4eight
1 2 3
16 -40 25
4 0 -16
0 15 60
[keys]$ ./a.out < data4eight

1x^2 + 2x + 3 = 0
Quadratic equation with complex roots.
x = -1.000+1.414i or x = -1.000-1.414i

16x^2 + -40x + 25 = 0
Quadratic equation with real roots.
x = 1.250

4x^2 + -16 = 0
Quadratic equation with real roots.
x = 2.000 or x = -2.000

15x + 60 = 0
Linear equation
x = -4.000

Here is the framework code, DO NOT CHANGE ANYTHING IN MAIN OR ADD ANY OTHER HEADER FILES:

// Purpose: This program is designed to compute the solutions to   

// a series of polynomial equations of the form:
// ax^2 + bx + c = 0
// Input: for each equation the program will read the three
// integer coefficients of the terms in the equation
// (a, b, and c)
// Output: the equation to be solved: ax^2 + bx + c = 0   
// (if coefficient is 0, term is not displayed)   
// the type of equation (linear or quadratic and type of roots)   
// solution(s) with labels and 3 digits to the right of the decimal   

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

void print_equation (int,int,int);
double linearroot (int,int);
void realroot (int,int,int);
void complexroot (int,int,int);

int main()
{
int a,b,c; // coefficients of the terms in the polynomial
int discrim; // discriminant of quadratic formula
double linear; // root of linear equation
cout << fixed << setprecision(3);
cout << \"name LecSec# LabSec# Exercise# \" << endl << endl;;
cin >> a;
while (cin)
{
cin >> b >> c;
print_equation(a,b,c); // display the equation in required format   
discrim = b * b - 4 * a * c;
if (a == 0)
{
cout << \"Linear equation\" << endl;
linear = linearroot(b,c); // compute and return linear solution
cout << \"x = \" << linear << endl;
}
else if (discrim >= 0)
realroot(a,b,c); // compute and print real solution(s)
else
complexroot(a,b,c); // compute and print complex solutions   
cout << endl;
cin >> a;
}
return 0;
}

void print_equation(int a, int b, int c)
// Given the coefficients: a, b, and c of a 2nd degree polynomial,   
// display the equation in the form: ax^2 + bx + c = 0   

// a, b, and c must be displayed as integers.
// Display only terms with non-zero coefficients.
// Examples:   
// if a = 3 b = -2 c = 5 display 3x^2 + -2x + 5 = 0
// if a = 0 b = -5 c = -3 display -5x + -5 = 0   
// if a = -4 b = 3 c = 0 display -4x^2 + 3x = 0
// Assume a, b, and c will define a solvable equation.   
// Assume at least one coefficient will be non-zero.   
{

}

double linearroot(int b, int c)
// Given the values of b and c in an equation of the form bx + c = 0,
// compute and return the value of x.
{

}

void realroot(int a, int b, int c)
// Given the coefficients of a 2nd degree polynomial where the roots   
// are real, solve for x1 and x2. Display the type of equation   
// (quadratic with real roots) and roots with labels and 3 digits to   
// right of decimal. If both roots are the same, display only one value
// for x.
{

}

void complexroot(int a, int b, int c)
// Given the coefficients of a 2nd degree polynomial where the roots   
// are complex, solve for the 2 imaginary roots. Display the type
// of equation (quadratic with complex roots) and the roots in   
// the form x + yi and x - yi with labels. x and y should be   
// displayed with 3 digits to the right of the decimal. Do not display   
// x + -yi and x - -yi.
{

}

Solution

I will complete the incomplete functions.fill these incomplete parts in your existing program

void realroot(int a, int b, int c)
{

printf(\"Roots are real numbers.\ \");
int x1,x2;
x1 = ( -b + sqrt(d)) / (2* a);
x2 = ( -b - sqrt(d)) / (2* a);
   printf(\"Roots of quadratic equation are: %.3f , %.3f\",x1,x2);

//linear case where a==0

double linearroot(int b, int c)

{

double x1=-b/2c;

printf(\"x1=%.3lf\",x1);

}

//complex roots

void complexroot(int a, int b, int c)

{

I need help with this programming assignment. There is code below. DO NOT CHANGE ANYTHING IN MAIN OR ADD HEADER FILES New Skills Practiced (Learning Goals) C++
I need help with this programming assignment. There is code below. DO NOT CHANGE ANYTHING IN MAIN OR ADD HEADER FILES New Skills Practiced (Learning Goals) C++
I need help with this programming assignment. There is code below. DO NOT CHANGE ANYTHING IN MAIN OR ADD HEADER FILES New Skills Practiced (Learning Goals) C++
I need help with this programming assignment. There is code below. DO NOT CHANGE ANYTHING IN MAIN OR ADD HEADER FILES New Skills Practiced (Learning Goals) C++

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site