quadratic equation

I trying to write this code for the quadratic equation. These are the instructions

�dEnhance the Quadratic program in the following manner. If the roots are not complex, Enhance the Quadratic program in the following manner. If the roots are not complex, compute the two roots of the quadratic equation using the formula:

x= -b + or - sqrt of d / 2a

Once the two roots are calculated, display them to the screen with a descriptive message. Note: At this point you should go back and change the PURPOSE comment at the top of the file – you have significantly changed what this program does!

It's based off of this code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/////////////////////////////////////////////////////////////////////////////
//
// Name: Quadratic.cpp
// Author: Jeffrey A. Stone
// Course: CMPSC 101/121
// Purpose: Prompts the user for the three coefficients of a quadratic
// equation, and determines if the user has entered sufficient
// values to represent a quadratic equation.
//
/////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
/////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: main
// PARAMETERS: None
// RETURN TYPE: int
// PURPOSE: Entry point for the application.
//
/////////////////////////////////////////////////////////////////////////////
int main()
{
double a = 0.0, b = 0.0, c = 0.0; // stores the coefficients
// prompt the user to enter three coefficients, separated by spaces...
cout << "Please enter the coefficients, separated by spaces: ";
cin >> a >> b >> c; // input the three values
// echo-print the input...
cout << endl
<< "You entered a = " << a << ", b = " << b
<< ", c = " << c << "." << endl;
if ( a == 0 )
{
// not a quadratic equation, display an error message...
cout << "ERROR: the first coefficient must not be zero." << endl;
}
else
{
// a valid quadratic equation, display an error message...
cout << "The coefficients are valid." << endl;
}
// exit the program with success (0 == success)
return 0;
}


I AM VERY NEW TO THE LANGUAGE. NOT ASKING TO SOLVE JUST TO EXPLAIN
Last edited on
closed account (iw0XoG1T)
Do you have a question?
Topic archived. No new replies allowed.