I have a text file with three values.
2.5 7.6 -3
I am trying to output the values in another text file, with a decimal point of 5 places. I have done this before with cout
, however I am having trouble implementing it to fout
. Below is me trying to do it similar to cout
.
ofstream fout("roots.txt");
fout << setprecision(5);
fout << "The equation " << setprecision(5) << a << "x^2 + " << setprecision(5) << b << "x + " << setprecision(5) << c << " has roots " << root1 << " and " << root2 << endl;
fout.close();
I expect the output in the text document to be
The equation 2.50000x^2 + 6.70000x + -3.00000 = 0 has roots 0.39078 and -3.07078.
Currently the output is: The equation 2.5x^2 + 7.6x + -3 has roots 0.35361 and -3.3936