Need someoe to finish my fine root program

HELLO EVERYONE! IM A NOVICE C++ USER AS I HAVE BEEN STUDYING THE SUBJECT FOR ABOUT 4 MONTHS NOW... I NEED HELP ON A PROGRAM IM WORKING ON THE INSTRUCTIONS FOLLOW....

WRITE A PROGRAM TO READ 3 NUMBERS FROM AN INPUT (IN.TXT) FILE (1,-5,6), THESE ARE COEFFICIENTS OF A QUADRATIC EQUATION. YOUR JOB IS TO USE THE QUADRATIC FORMULA AND FIND THE ROOTS OF THIS EQUATION. PRINT THE ROOTS AND OUTPUT THE FILE (OUTPUT.TXT)

FORMULA TO FIND ROOTS X = -b+(-)(open square root)b^2-4ac DIVIDED BY 2a

Keep in mind that B^2 - 4ac <0 you have to imaginairy solution
if b^2-4ac = 0 you have one real solution
and if b^2-4ac >0 then you have two real solutions

YOUR FUNCTION HEADER SHOULD LOOK LIKE
VOID ROOTS (INT A, INT B, INT C, INT & r1, int & r2)


THANKS FOLKSSS :)))))




This is wat i have so far

#include <cmath> //This might help later.
void roots(int A, int B, int C, int& r1, int& r2)
{
int squirt = B*B - 4*A*C;
if (squirt < 0)
std::cerr << "Imaginary solution. \nThis function cannot handle these because you demanded ints instead of complex<int>s to be the types of r1 and r2.";
else if (squirt = 0)
{
//Code here.
}
else if (squirt > 0)
{
//Code here. Remember to account for the +/-!
}
}




Okay. I was happy to give you that template there, but we don't give out full solutions to homework problems around here, and we have some good reasons why, too.

I should write an article.

-Albatross
Topic archived. No new replies allowed.