Hey i am currently really stuck on a school assignment. No rush i have plenty of time, but without a little help i am pretty much lost.

The question is as fallows.

Design a class named QuadraticEquation for a quadratic equation ax2 + bx + c = 0. (The book has an error in the quadratic expression.)

The class contains:

Attributes a, b, and c that represent three coefficients.

A constructor for the arguments a, b, and c.

Three get functions for a, b, and c.

A method names getDiscriminant() that returns the discriminant, which is b2 - 4ac.

Methods names getRoot1() and getRoot2() for returning two roots of the equation: (see book for the complete mathematical formula)

The roots of a quadratic are undefined (in the real number system) if the discriminant is negative. If the discriminant is negative, let getRoot1() and getRoot2() return the value zero (0).

(We will eventually see a better way to handle the zero discriminant problem in C++.)

Draw the UML diagram for the class. Implement the class. Write a test program that prompts the user to enter values for a, b, and c, then displays the roots based on the discriminant. If the discriminant is positive, display the two roots. If the discriminant is zero (0) display the one root. If the discriminant is negative, display "The equation has no real roots."

I was told i have everything to my disposal for research, so i assume your allowed to help me.

Question, the class is only the header file right, so i am pretty sure i don't have to implement this, further than than simple testing to make sure it all works, i also don't have to write my main.cpp file if im not mistake.

What i have so far:

Quadradicequation.h

```
#ifndef QUADRADICEQUATION_H
#define QUADRADICEQUATION_H
class Quadradicequation
public:
void getcoefficients()
{
int get.a(a);
int get.b(c);
int get.c(c);
void get.discrim(discrim);
void get.root1(root1);
void get.root2(root2);
}
private:
void coefficients()
{
int a, b, c;
double result;
result = sqrt(b^2 - (4*a*c));
int set.a(a);
int set.b(b);
int set.c(c);
void set.descrim(b^2-(4*a*c);
void set.root1((-b+result)/(2*a));
void set.root2((-b-result)/(2*a));
}
```

Quadradicequation.cpp

```
#include "Quadradicequation.h"
using namespace std;
void getcoefficients();
{
cout << "Enter Values for a b and c: ";
int a, b, c;
cin >> a >> b >> c;
Quadradicequation::get.discrim(discrim);
if (discrim = 0)
get.root1(root1);
else if (discrim > 0)
get.root1(root1);
get.root2(root2);
else
cout << "The equation has no real roots." << endl;
```

Other than that i am not going to lie. Anyone have any literature that doesn't suck as much as my text book?

Any help is great

Thanks,

~E

*Edited 5 Years Ago by epew23*: n/a