### 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.

Thank You

//////////////////////////ASSIGNMENT///////////////////////////////////////
Problem
Design a class named quadratic that represents a polynomial of degree 2. Here is the
p = ax2 + bx + c, a, b, c ∈ ℜ and a ≠ 0
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

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 "pa2functions.h"

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

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

//inputs values for quadratic 1 & 2

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

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

return EXIT_SUCCESS;
}

////////////////////////////////pa2functions.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

//Display Results

#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
{
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
{
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
{
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 << "Quadratic 1 evaluated at given x: " << _A.evaluate_x << endl;

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

cout << "The solution to the sum of quadratic 1 & 2." << endl;

}

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

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

//Constructor

//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 evaluate_x(void);

};

#endif

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

//PRE: none
{
return a;
}
{
return b;
}
{
return c;
}
{
return x;
}

{
a = A;
}
{
b = B;
}
{
c = C;
}
{
x = D;
}

//PRE: none
{
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);
}
}

{
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);
}
}
//PRE: none
//POST: returns x_evaluated
{
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;
}

{

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
 ``12`` `````` std::cin >> A; std::cout << endl; ``````
Topic archived. No new replies allowed.