Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C + + . Make a quadratic equation solver using this template. And explain each step This is a program to give the solutions

In C++. Make a quadratic equation solver using this template. And explain each step
This is a program to give the solutions to a quadratic equation.
The user will enter the three coefficients of the equation.
Let's call them a, b, c. So the equation is ax^2+ bx + c =0
By the quadratic formula the solutions are
x1=-b + sqrt(b^2-4ac) all divided by 2a.
x2=-b - sqrt(b^2-4ac) all divided by 2a.
Note: In the C++ code we need to be very careful about
the order in which arithmetic operations are performed.
For the output we'll round to three digits after the decimal point
and we'll place the result in a "column" as shown below
x1=45.567
x2=1234.200
*/
#include
using namespace std;
int main()// This is a single line comment
{
double a, b, c, x1, x2, discriminant;
// prompt the user for three coefficients
// input statement for a, b and c.
// Set discriminant to b squared minus 4 times ac.
// Two more assignment statements...
// First assignment statement gives x1 a value.
// Second assignment statement gives x2 a value.
// Output the result to the console e.g.
// x1=45.676
// x2=3456.200
// NOTICE: The outputs are formated using setw
// and the number of digits after the decimal point
// is 3.
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+What is the response variable?

Answered: 1 week ago