Homework Assignment infile / outfiles
<p>My assignment states the following :</p>
<blockquote>
<p>Three employees in a company are up for a special pay increase. You are given a file, <code>Ch3_Ex7Data.txt</code>, with the following data:</p>
<p>Miller Andrew 65789.87 5<br>
Green Sheila 75892.56 6<br>
Sethi Amit 74900.50 6.1</p>
<p>Each input line consists of an employee's last name, first name, current salary, and percent pay increase.</p>
</blockquote>
<p>For example, in the first input line, the last name of the employee is <code>Miller</code>, the first name is <code>Andrew</code>, the current salary is <code>65789.87</code>, and the pay increase is <code>5 %</code>.</p>
<blockquote>
<p>Write a program that reads data from the specified file and stores the output in the file <code>Ch3_Ex7Output.dat</code>. For each employee, the data must be output in the following form: <br><code>firstName lastName updatedSalary</code><br> Format the output of decimal numbers to two decimal places.</p>
</blockquote>
<p>My code is the following.</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;iomanip&gt;
#include &lt;string&gt;

using namespace std;

int main()
{
    //Declaring the variables
    string firstName;
    string lastName;
    double payIncrease;
    double pay;
    ifstream inFile;
    ofstream outFile;

    inFile.open(&quot;C:\\Users\\Megan\\Ch3_Ex7Data.txt&quot;); //opens the input file
    outFile.open(&quot;C:\\Users\\Megan\\Ch3_Ex7Output.dat&quot;); //opens a output file

    outFile &lt;&lt; fixed &lt;&lt; showpoint;
    outFile &lt;&lt; setprecision(2); // Output file only having two decimal places
    cout &lt;&lt; &quot;Processing Data.....&quot; endl;  //program message

    while (!inFile.eof() //loop
        inFile &gt;&gt; lastName &gt;&gt; firstName &gt;&gt; pay &gt;&gt; payIncrease;
        pay = pay*(pay*payIncrease);
        outFile &lt;&lt; firstName &lt;&lt; &quot; &quot; &lt;&lt; lastName &lt;&lt; &quot; &quot; &lt;&lt; pay &lt;&lt; &quot;/n&quot;;

    inFile.close();
    outFile.close();

    return 0;
}
</code></pre>
<p>For some reason I cannot seem to get the code to open my existing <code>.txt</code> file, read it and then translate it to another file. Does anybody see anything wrong with this that could help me out?</p>