#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
usingnamespace std;
int main()
{
ifstream inFile;
double a, b, c;
double linroot;
double quadroot1, quadroot2; // resulting roots
double discriminant;
cout << showpoint << fixed << setprecision(2);
cout << "COMPUTE THE REAL ROOT(S)";
cout << "OF A QUADRATIC OR A LINEAR EQUATION\n\n";
cin >> Filename;
inFile.open();
inFile >> a;
inFile >> b;
inFile >> c;
while (a != -9999 && b != -9999 && c != -9999)
{
discriminant = b * b - (4 * a * c);
if (a == 0 && b == 0)
cout << "No linear or quadratic equation is formed.\n\n";
elseif (discriminant < 0)
cout << "Roots are not real.\n\n";
elseif (a == 0)
{
linroot = -1 * (c / b);
cout << "Root is " << linroot << " .\n\n";
}
else
{
quadroot1 = (-b + pow(discriminant, .5)) / (2 * a);
quadroot2 = (-b - pow(discriminant, .5)) / (2 * a);
cout << "Roots are " << quadroot1 << " and " << quadroot2 ;
}
inFile >> a;
inFile >> b;
inFile >> c;
}
inFile.close ();
cout << "Programmer: ";
return 0;
}
It's supposed to calculate the zeros of a quadratic and linear equation. It generates error numbers 2605 and 2661. I'm still unclear about how to successfully get a file using cin. Help would be greatly appreciated. Thanks.
one error comes from line 18. open() needs some arguments. see http://www.cplusplus.com/reference/iostream/fstream/open/
I don't see the other one though. Which line is it form?
By the way, it would be good if you, in your future posts, would write more than the error code.
I have errors listed at 27 and 28. I confused about how to get the user to input a file . A lot of the file input/output material i've read has the file specified in the code. Next time I'll try to post more than error code. I just joined today because of this problem.