Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well.. my guess is this is what your looking for:</p> <p>Note that the:</p> <pre><code>if ((hours &lt;= 0) &amp;&amp; (rate &lt;= 0)) </code></pre> <p>is changed to:</p> <pre><code>if ((hours &lt;= 0) || (rate &lt;= 0)) </code></pre> <p>otherwise it won't ever hit the "invalid data" with your supplied data</p> <pre><code>//***************************** // This program is to help calculate an employee's weekly gross pay as well as // the net pay while showing the taxes that were taken off. // The data that will be shown will be calculated from a .txt file // that was created and called employee.txt. // Input: Will be the inFile known as employee.txt // Output: Gross pay, taxable income, federal tax, state tax, and net pay // Typed by: // Date: //****************************** #include &lt;iomanip&gt; #include &lt;fstream&gt; #include &lt;iostream&gt; using namespace std; float computeGross(float, float); void computeTaxes(float, float&amp;, float&amp;, float&amp;); float computeNetPay (float&amp;, float&amp;, float&amp;, float&amp;); const float hours = 40; // Regular 40 hour work week const float ovTime = 1.5; // Overtime if hours go over 40 const float exemption = 200.0; // Exemption if pay goes over 200 const float fedTaxRate = 0.10; // Federal Tax Rate const float stTaxRate = 0.03; // State Tax rate int main() { ifstream inFile ("employee.txt"); ofstream outFile ("result.txt"); float hours, rate, grossPay, taxableIncome, fedTax, stTax, NetPay; if (inFile.is_open()) { while (! inFile.eof() ) { inFile &gt;&gt; hours; inFile &gt;&gt; rate; if ((hours &lt;= 0) || (rate &lt;= 0)) { outFile &lt;&lt; "Invalid Data"; } else { grossPay = computeGross(hours, rate); computeTaxes (grossPay, taxableIncome, fedTax, stTax); computeNetPay (grossPay, fedTax, stTax, NetPay); outFile &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2); outFile &lt;&lt; "Hours worked = " &lt;&lt; hours &lt;&lt; endl &lt;&lt; "Hourly rate = " &lt;&lt; rate &lt;&lt; endl &lt;&lt; "Employee's gross pay = " &lt;&lt; grossPay &lt;&lt; endl &lt;&lt; "Taxable Income = " &lt;&lt; taxableIncome &lt;&lt; endl &lt;&lt; "Federal Taxes = " &lt;&lt; fedTax &lt;&lt; endl &lt;&lt; "State Taxes = " &lt;&lt; stTax &lt;&lt; endl &lt;&lt; "Net Pay = " &lt;&lt; NetPay &lt;&lt; endl; } } } return 0; } </code></pre> <p>The rest is the same</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload