HW help .. think I'm close

Assignment followed by my program files currently.

I am getting an error code w/ no specific lines. Might be an issue with my #include.

I'm stuck and would appreciate any helpful comments.

Thank You

//////////////////////////ASSIGNMENT///////////////////////////////////////
Problem
Design a class named quadratic that represents a polynomial of degree 2. Here is the
form of a quadratic polynomial.
p = ax2 + bx + c, a, b, c ∈ ℜ and a ≠ 0
Use your quadratic class to perform the following tasks.
1. Solve quadratic equations.
2. Compute the sum of two quadratics using an overloaded operator +.
3. Evaluate the two quadratics at a value, x.

Input
Values a1, b1, c1 and a2, b2, c2 for two quadratics and a value x to evaluate both
quadratics.

Output
1. Two quadratics in tuple form (a, b, c).
2. The results computed from the sum of the two input quadratics.
3. The results of the two quadratics when evaluated at the point x.
4. The real solutions to both quadratics as given by the quadratic formula.

////////////////////////////////Program begins////////////////////////////////
/////////////////////////////////MAIN/////////////////////////////////////////

#include "quadratic.h"
#include "pa2functions.h"


int main()
{
//Creates obj A & B of type Quadratic
Quadratic A;
Quadratic B;

//Message stating the purpose and use of the program
greeting();

//inputs values for quadratic 1 & 2
inputValue_quad(&A);
inputValue_quad(&B);

//inputs value of x to be evaluated
inputValue_X(&A, &B);

//Prints results
print_results(&A, &B);

return EXIT_SUCCESS;
}

////////////////////////////////pa2functions.h////////////////////////////////

#include "quadratic.h"
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>

#ifndef PA2_FUNCTIONS_H
#define PA2_FUNCTIONS_H

//User Message Prompt
void greeting(void);

//User Input Functions
void inputValue_quad(Quadratic &);
void inputValue_X(Quadratic &, Quadratic &);

//Display Results
void print_results(Quadratic &, Quadratic &);

#endif

/////////////////////////////////////pa2functions.cpp//////////////////////////



//PRE: none
//POST:User Message Prompt
void greeting(void)
{
using std::cout;
using std::endl;

cout << "This program accepts input variables";

}

//PRE: none
//POST: Values input/set on obj A
void inputValue_quad(Quadratic & _A)
{
double A;
double B;
double C;

std::cout << "Please enter values for A, B, C for the 1st quadratic " << std::endl;
std::cout << "separated by spaces: " << std::endl;

std::cin >> A >> std::endl;
std::cin >> B >> std::endl;
std::cin >> C >> std::endl;

_A.setValue_a(A);
_A.setValue_b(B);

_A.setVAlue_c(C);
}


//PRE: none
//POST: Value of x for both obj A & B set
void inputValue_x(Quadratic & _A, Quadratic & _B)
{
double X;

std::cout << "Please enter the value of X at which you would like to " << std::endl;
std::cout << "evaluate the quadratics: " << std::endl;

std::cin >> X;

_A.setValue_x(X);
_B.setValue_x(X);
}

//PRE: none
//POST: Prints results to screen
void print_results(Quadratic &_A, Quadratic &_B)
{
using std::cout;
using std::cin;
using std::endl;

cout << "(" << _A.getValue_a() << ", " << endl;
cout << "(" << _A.getValue_b() << ", " << endl;
cout << "(" << _A.getValue_c() << endl;

cout << "(" << _B.getValue_a() << ", " << endl;
cout << "(" << _B.getValue_b() << ", " << endl;
cout << "(" << _B.getValue_c() << endl;


cout << "Solution to Quadratic 1: " << _A.solveQuadratic_plus << endl;
cout << "Solution to Quadratic 1: " << _A.solveQuadratic_minus << endl;

cout << "Quadratic 1 evaluated at given x: " << _A.evaluate_x << endl;


cout << "Solution to Quadratic 2: " << _B.solveQuadratic_plus << endl;
cout << "Solution to Quadratic 2: " << _B.solveQuadratic_minus << endl;

cout << "Quadratic 2 evaluated at given x: " << _B.evaluate_x << endl;


cout << "The solution to the sum of quadratic 1 & 2." << endl;
Quadratic quad_sum = _A + _B;
cout << quad_sum;

}

/////////////////////////////////////quadratic.h////////////////////////////


#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>

#ifndef QUADRATIC_H
#define QUADRATIC_H

class Quadratic
{
public:
//Initializes variables a, b, c, x,
double a,b,c;
double x;


//Constructor
Quadratic(double, double, double);

//Getter functions
double getValue_a(void);
double getValue_b(void);
double getValue_c(void);
double getValue_x(void);

//Setter functions
void setValue_a(double const );
void setValue_b(double const );
void setValue_c(double const );
void setValue_x(double const );

//Mathematical functions
double solveQuadratic_plus(void);
double solveQuadratic_minus(void);
double evaluate_x(void);

//Overloaded functions
friend Quadratic operator+(Quadratic _D);
};

#endif

//////////////////////////////quadratic.cpp/////////////////////////////////



//CONSTRUCTOR
Quadratic::Quadratic(double const A = 1.0, double const B = 0.0,
double const C = 0.0): a(A), b(B), c(C)
{
}

//PRE: none
//POST: returns quad obj values
double Quadratic::getValue_a(void)
{
return a;
}
double Quadratic::getValue_b(void)
{
return b;
}
double Quadratic::getValue_c(void)
{
return c;
}
double Quadratic::getValue_x(void)
{
return x;
}



void Quadratic::setValue_a(double const A)
{
a = A;
}
void Quadratic::setValue_b(double const B)
{
b = B;
}
void Quadratic::setValue_c(double const C)
{
c = C;
}
void Quadratic::setValue_x(double const D)
{
x = D;
}

//PRE: none
//POST: returns quadratic solution
double Quadratic::solveQuadratic_plus(void)
{
double quadratic_solution;
double D;
D = ((b * b) - (4 * a * c));


if(D < 0)
{
std::cerr << "Insufficient Funds";
return EXIT_FAILURE;
}
else
{
quadratic_solution = (-b + sqrt(D))/(2 * a);
return quadratic_solution;
}
}

double Quadratic::solveQuadratic_minus(void)
{
double quadratic_solution;
double D;
D = ((b * b) - (4 * a * c));


if(D < 0)
{
std::cerr << "Insufficient Funds";
return EXIT_FAILURE;
}
else
{
quadratic_solution = (-b - sqrt(D))/(2 * a);
return quadratic_solution;
}
}
//PRE: none
//POST: returns x_evaluated
double Quadratic::evaluate_x()
{
double x_evaluated;
double term1;
double term2;
double term3;

term1 = a* (x * x);
term2 = b * x;
term3 = c;
x_evaluated = term1 + term2 + term3;

return x_evaluated;
}

Quadratic operator+(Quadratic &left, Quadratic &right)
{
Quadratic temp;

temp = left.a + right.a;
temp = left.b + right.b;
temp = left.c + right.c;

return temp;
}

Please include all your code in [ Code] [ /Code] tags to make it easier to read.
Pasting as much of the error as you can can still help us (even if it doesn't give specific line numbers).

From the code you have given it doesn't look like you are including anything in your .cpp files. For example in quadratic.cpp you need to include quadratic.h or else your main function wont be able to see any of the functions when they all get linked together.

You need parenthesis on all functions calls, check stuff like
cout << "Solution to Quadratic 1: " << _A.solveQuadratic_plus << endl;
(There are quite a lot of mistakes with this).

You can't add endl onto the end of cin like this.
std::cin >> A >> std::endl;

You would want to use
1
2
 std::cin >> A;
 std::cout << endl; 
Topic archived. No new replies allowed.