I'm writing this program that calculates the amount of hours that employees work. If the employee ends up working more than 40 hours, than he'll get an additional time and half for every hour that passes 40. My issue is when it comes to the output. In the output, it shows the amount of sales tax, federal tax, gross income, and net; however if the employee puts in that he has worked less than 40 hours, everything displays properly; however, once the employee puts in that he has worked more than 40 hours for some reason it shows the taxes, and net, gross as 0.00.
For example, if less than 40, the following would display.
F-Name: L-Name: HorsWrked: HrlyRate: TimeHalf: S-Tax: F-Tax: Fica: Gross:
Employee Last 39.00 22.00 1.50 60.06 128.70 34.32 858.00
If more than 40, the following is being displayed.
F-Name: L-Name: HorsWrked: HrlyRate: TimeHalf: S-Tax: F-Tax: Fica: Gross:
Employee Last 45.00 22.00 1.50 0.00 0.00 0.00 0.00
Any tips, hints, advice is appreciated.``
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//Set variables
int const size = 2;
double timeHalf = 0.0, hoursWorked[size], gross[size], net[size], hourlyRate[size], totalTax;
string firstName[size], lastName[size];
const double stateTax = 0.07, fedTax = 0.15, fica = 0.04;
double sTax = 0.0, fTax = 0.0, fiTax;
for(int i = 0; i < size; i++) //Initialize for loop
{
cout<<"Please enter your first name? " <<endl; //Display first name
cin>>firstName[i];
cout<<"Please enter your last name? " <<endl; //Display last name
cin>>lastName[i];
cout<<"How many hours did you work? " <<endl; //Dispaly hours worked
cin>>hoursWorked[i];
cout<<"What's the hourly rate? " <<endl; //Display hourly rate
cin>>hourlyRate[i];
if(hoursWorked[i] < 40)
{
gross[i] = hoursWorked[i] * hourlyRate[i];
}
else if( hoursWorked[i] > 40)
{
gross[i] = hoursWorked[i] * (hourlyRate[i] * timeHalf);
}
}
cout<<" \t\tXYX \n ";
cout<<"F-Name: L-Name: HorsWrked: HrlyRate: TimeHalf: S-Tax: F-Tax: Fica: Gross: Net: \n";
for(int i = 0; i < size; i++)
{
sTax = gross[i] * stateTax;
fTax = gross[i] * fedTax;
fiTax = gross[i] * fica;
totalTax = gross[i] * (stateTax + fedTax + fica);
timeHalf = 1.5;
net[i] = gross[i] - totalTax;
cout<<firstName[i]<<"\t " << setw(10) <<fixed <<setprecision(2) << lastName[i]<<"\t "
<< hoursWorked[i]<<"\t " <<hourlyRate[i] <<"\t " <<timeHalf<<"\t " <<sTax <<"\t "
<<fTax <<"\t " <<fiTax <<"\t " <<gross[i] <<"\t " <<net[i] <<"\t ";
}
}
Because in your conditions, you check if(hoursWorked[i] < 40) and if(hoursWorked[i] > 40), but there is no condition for if(hoursWorked[i] == 40). You probably wanted to use -or-equal operator on one of these conditions (>= or <=).
Related
I'm currently doing a Zybooks lesson for my C++ class and we're going over while loops. In this question, it wants me to calculate how many years it takes for a bank account to double it's initial balance. There is also an annual contribution added. My code is as follows:
#include <iostream>
using namespace std;
int main()
{
const double RATE = 5;
const double INITIAL_BALANCE = 10000;
const double TARGET = 2 * INITIAL_BALANCE;
cout << "Annual contribution: " << endl;
double contribution;
cin >> contribution;
double balance = INITIAL_BALANCE;
int year = 0;
while (balance < TARGET)
{
year++;
double interest = balance * RATE / 100;
balance = balance + interest + contribution;
}
cout << "Year: " << year << endl;
cout << "Balance: " << balance << endl;
return 0;
}
I used this as an answer but was met with this unexpected result:
Output differs. See highlights below.
Input
100
Your output
Annual contribution:
Year: 13
Balance: 20627.8
Expected output
Annual contribution:
Year: 13
Balance: 20527.8
I see the expected output and your output differs by a 100, i.e. your contribution. Maybe the evaluation system doesn't add annual contribution once your target is reached. The below code gets your required output, but I think your code should have been the correct answer.
#include <iostream>
using namespace std;
int main()
{
const double RATE = 5;
const double INITIAL_BALANCE = 10000;
const double TARGET = 2 * INITIAL_BALANCE;
cout << "Annual contribution: " << endl;
double contribution;
cin >> contribution;
double balance = INITIAL_BALANCE;
int year = 0;
while (balance < TARGET)
{
year++;
double interest = balance * RATE / 100;
balance = balance + interest;
if (balance < TARGET) {
balance += contribution;
}
}
cout << "Year: " << year << endl;
cout << "Balance: " << balance << endl;
return 0;
}
The problem is that you're making a contribution after the 13th year even though the target has been reached.
I would restructure to something like this, in order to only check the condition once:
while (true)
{
year++;
double interest = balance * RATE / 100;
balance += interest;
if (balance >= TARGET)
{
break;
}
balance += contribution;
}
This is because the last time the loop is being executed (at year=13), balance is less than TARGET but, after adding a contribution and interest into it, it jumps out of the loop with contribution and interest added to it.
So, the solution can be to use an if statement within the while loop to check if it exceeds the TARGET; if it does, then don't add contribution into it.
Replace your while loop with the following:
while (balance < TARGET)
{
year++;
double interest = balance * RATE / 100;
balance = balance + interest;
if (balance < TARGET) {
balance += contribution;
}
}
First time posting here. Recently started a C++ class and I'm really enjoying it! I'm creating a tax computing program but ran into a bit of wall on this part. I don't know how its not initialized if I already stated it using 'double'
The variable that I'm having trouble with is "taxes2" on line 129
Please help if you can!
Also, this is the prompt im working with:
"Write a program to compute income tax as follows:
First, read the income for the year. Then, display the following menu and ask the user to select his or her filing status:
Single
Married filing separately
Married filing jointly
Head of household
For Single status, apply a deduction of $2000, for #2 $1700, for #3, $2300 and Head of household $2700. Also, ask for and read the number of dependents. Add to the deduction amount, $150 for each dependent up to a maximum of 3 dependents if single, add $125 for each dependent up to a maximum of 4 for Married filing separately, and $175 for each dependent, up to a maximum of 5, if married filing jointly or head of household.
Then, compute the taxable income by subtracting the total deduction computed above from his or her income. Anyone with a taxable income of less than $8,000 pays no taxes. For the rest, the first $15,000 of the income has a tax rate of 10%, the next $25,000 gets taxed at 15%, the next $30,000 at 20%, the next $30,000 at 25% and anything above $100,000 at 30%. So, for example, someone who had taxable income of $125,000, her first $15,000 gets taxed at 10% ($1,500), plus 15% of $25,000 ($3,750), plus 20% of $30,000 ($6,000), plus 25% of $30,000 ($7,500) and the remaining $25,000 at 30% ($7,500) for a total tax amount of $26,250. For someone with income of $13,000, the tax is 10% of that or $1,300. For someone who made $7,999.99 it would be 0, but for someone who made $8,000, it's $800. For someone who made $30,000, it would be 10% of $15,000 or $1,500 plus 15% of the remaining $15,000 or $2,250 making it $3,750, and so on. Display the amount of taxes to be paid."
#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
const double tax1 = 1500.00;
const double tax2 = 3750.00;
const double tax3 = 6000.00;
const double tax4 = 7500.00;
double income;
double istatus;
double itaxes;
double itaxes2;
double ideduction1;
double ideduction2;
double idependant;
const double idependantrate1 = 150;
const double idependantrate2 = 125;
const double idependantrate3 = 175;
double idependanttotal;
cout << "What is your income? " << endl;
cin >> income;
cout << "Please enter your filing status: \n";
cout << "1. Single \n";
cout << "2. Married Filing Separately \n";
cout << "3. Married Filing Jointly \n";
cout << "4. Head of Household \n";
cin >> istatus;
// Begin Deductions
if (istatus == 1)
{
cout << "You've selected Single";
ideduction1 = 2000;
cout << "Please select number of dependants (max: 3): ";
cin >> idependant;
if (idependant >= 0)
{
idependant * idependantrate1 == idependanttotal;
}
idependanttotal + ideduction1 == ideduction2;
}
else if (istatus == 2)
{
cout << "You've selected Married Filing Separately";
ideduction1 = 1700;
cout << "Please select number of dependants (max: 4): ";
cin >> idependant;
if (idependant >= 0)
{
idependant * idependantrate2 == idependanttotal;
}
idependanttotal + ideduction1 == ideduction2;
}
else if (istatus == 3)
{
cout << "You've selected Married Jointly";
ideduction1 = 2300;
cout << "Please select number of dependants (max: 5): ";
cin >> idependant;
if (idependant >= 0)
{
idependant * idependantrate3 == idependanttotal;
}
idependanttotal + ideduction1 == ideduction2;
}
else if (istatus == 4)
{
cout << "You've selected Head of Household";
ideduction1 = 2700;
cout << "Please select number of dependants (max: 5): ";
cin >> idependant;
if (idependant >= 0)
{
idependant * idependantrate3 == idependanttotal;
}
idependanttotal + ideduction1 == ideduction2;
}
// Calculate Income Taxes
if (income <= 7999.99)
{
cout << "No taxes need to be paid. " << endl;
return 0;
}
else if (income >= 8000.00 && income <= 15000.00)
{
itaxes = income * .10; //calculates tax amount
itaxes - ideduction2 == itaxes2;
cout << "The amount owed in taxes is: $" << itaxes2 << endl;
}
else if (income >= 15000.01 && income <= 40000.00)
{
itaxes = ((income - 15000) * .15) + tax1; //calculates tax amount
itaxes - ideduction2 == itaxes2;
cout << "The amount owed in taxes is: $" << itaxes2 << endl;
}
else if (income >= 40000.01 && income <= 70000.00)
{
itaxes = ((income - 40000) * .20) + tax1 + tax2; //calculates tax amount
itaxes - ideduction2 == itaxes2;
cout << "The amount owed in taxes is: $" << itaxes2 << endl;
}
else if (income >= 70000.01 && income <= 100000.00)
{
itaxes = ((income - 70000) * .25) + tax1 + tax2 + tax3; //calculates tax amount
itaxes - ideduction2 == itaxes2;
cout << "The amount owed in taxes is: $" << itaxes2 << endl;
}
else if (income > 100000.01)
{
itaxes = ((income - 100000) * .30) + tax1 + tax2 + tax3 + tax4; //calculates tax amount
itaxes - ideduction2 == itaxes2;
cout << "The amount owed in taxes is: $" << itaxes2 << endl;
}
else
cout << "You have entered an unuseable number. Please restart the program and enter a positive number " << endl;
return 0;
idependant * idependantrate1 == idependanttotal will calculate the value of idependant * idependantrate1, and then check if it equals idependanttotal. If you want to store the calculated value in idependanttotal write idependanttotal = idependant * idependantrate1;.
Apparently there is a calculation error somewhere in my program, but I simply can’t find it.
The only information I have as to why there is a calculation error is this following feedback given by MyProgrammingLab (A site that automatically tests code to see if it's incorrect or not). I don't know what values were entered for the annual death rate and annual birth rate to cause it. Could it be that I'm right but MyProgrammingLab is wrong? Honestly, all my own tests seem fine.
Expected Output:
Year 1: 200 176
Year 2: 176 154
Year 3: 154 135
Year 4: 135 118
Year 5: 118 103
Year 6: 103 90
Year 7: 90 79
Actual Output:
Year 1: 200 199
Year 2: 199 198
Year 3: 198 197
Year 4: 197 196
Year 5: 196 195
Year 6: 195 194
Year 7: 194 193
I built the program according to the following assignment:
In a population, the birth rate is the percentage increase of the population due to births, and the death rate is the percentage decrease of the population due to deaths. Write a program that asks for the following:
The starting size of a population (minimum 2) (Prompt Enter starting size:)
The annual birth rate (Prompt Enter annual birth rate:)
The annual death rate (Prompt Enter annual death rate:)
The number of years to display (minimum 1) (Prompt Enter years to display:)
The program should then display the starting population and the projected population at the end of each year. It should use a function that calculates and returns the projected new size of the population after a year. The formula is
N = P(1 + B)(1 - D)
where N is the new population size, P is the previous population size, B is the birth rate, and D is the death rate. Annual birth rate and death rate are the typical number of births and deaths in a year per 1000 people, expressed as a decimal. So, for example, if there are normally about 32 births and 26 deaths per 1000 people in a given population, the birth rate would be .032 and the death rate would be .026.
My code:
#include <iostream>
using namespace std;
int projectedNewSize(float population, float annualBirthRate, float annualDeathRate) {
float annualBirthRate2 = annualBirthRate / 1000;
float annualDeathRate2 = annualDeathRate / 1000;
int newpopulation = population * (1 + annualBirthRate2) * (1 - annualDeathRate2);
return newpopulation;
}
int main() {
int populationStartingSize = 0;
float annualBirthRate = 0;
float annualDeathRate = 0;
int numberOfYearsToDisplay = 0;
do {
cout << "Enter starting population size: ";
cin >> populationStartingSize;
cout << "Enter annual birth rate: ";
cin >> annualBirthRate;
cout << "Enter annual death rate: ";
cin >> annualDeathRate;
cout << "Enter years to display: ";
cin >> numberOfYearsToDisplay;
} while (!(populationStartingSize >= 2) || !(numberOfYearsToDisplay >= 1));
int population;
for (int i = 1; i <= numberOfYearsToDisplay; i++) {
cout << "Year " << i << ": " << populationStartingSize << " ";
population = projectedNewSize(populationStartingSize, annualBirthRate, annualDeathRate);
cout << population << endl;
populationStartingSize = population;
}
system("pause");
return 0;
}
So, The answer is
There is no need to divide the annualBirthRate and the annualDeathRate by 1000. Since annualBirthRate is calculated as annual births per 1000 of a population, It need not be divided by 1000 again.
Thus removing these lines
float annualBirthRate2 = annualBirthRate / 1000;
float annualDeathRate2 = annualDeathRate / 1000;
and changing
int newpopulation = population * (1 + annualBirthRate2) * (1 - annualDeathRate2);
to
int newpopulation = population * (1 + annualBirthRate) * (1 - annualDeathRate);
So, the final code would look like this:
#include <iostream>
using namespace std;
int projectedNewSize(float population, float annualBirthRate, float annualDeathRate) {
int newpopulation = population * (1 + annualBirthRate) * (1 - annualDeathRate);
return newpopulation;
}
int main() {
int populationStartingSize = 0;
float annualBirthRate = 0;
float annualDeathRate = 0;
int numberOfYearsToDisplay = 0;
do {
cout << "Enter starting population size: ";
cin >> populationStartingSize;
cout << "Enter annual birth rate: ";
cin >> annualBirthRate;
cout << "Enter annual death rate: ";
cin >> annualDeathRate;
cout << "Enter years to display: ";
cin >> numberOfYearsToDisplay;
} while (!(populationStartingSize >= 2) || !(numberOfYearsToDisplay >= 1));
int population;
for (int i = 1; i <= numberOfYearsToDisplay; i++) {
cout << "Year " << i << ": " << populationStartingSize << " ";
population = projectedNewSize(populationStartingSize, annualBirthRate, annualDeathRate);
cout << population << endl;
populationStartingSize = population;
}
system("pause");
return 0;
}
You guys discussed in the comments section and left the question unanswered..
int projectedNewSize(float population, float annualBirthRate, float annualDeathRate) {
int newpopulation = roundf(population * (1.0 + annualBirthRate) * (1.0 - annualDeathRate);
return newpopulation;
}
In the calculatiton you dont have to consider the factor of 1000 if it is already done in the input values. But if you want a 'most accurate' table you have to round the values in a proper mind. The return of the calculation is a float. If you assign it to an int - it always will be truncated. A little difference wich will be carried over from one loop to the next, ending up in some reasonable differences to the expected values at the end. The most proper way would be to change the type of 'newcalculation' to float and round only when display the value.
N = P + BP - DP
Program asked for birthrate and death rate, assume user entered 5 for 5%.
Basic math needs to be calculated here 5/100 = 0.05
The formula is now
N = P + (BP/100) - (DP/100)
Replace
float annualBirthRate2 = annualBirthRate / 1000;
float annualDeathRate2 = annualDeathRate / 1000;
int newpopulation = population * (1 + annualBirthRate2) * (1 - annualDeathRate2);
With
int newpopulation = population + (population * birthRate/100) - (population * deathRate/100)
I have a problem with my program and I would appreciate help.
It's supposed to allow you to enter an account number, a service code, and the number of minutes the service was used. The program then calculates the bill and it varies depending on your service. When I execute the program, it doesn't allow you to enter anything.
Regular service:$10.00 plus first 50 minutes free. Charges for over 50 minutes are $0.20 per minute.
Premium service:
$25.00 plus:
a)
For calls made from 6:00 am to 6:00 pm, the first 75 minutes are free; charges for over
75 minutes are $0.10 per minute.
b)For calls made from 6:00 pm to 6:00 am, the first 100 minutes are free; charges for over 100 minutes are $0.05 per minute.
Here is the program that I've typed.
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
int minutes = 0,
day_minutes = 0, //minutes used during the day
night_minutes = 0; //minutes used during the night
string service_code,
account_number;
double final_amount,
final_damount, //final amount for day minutes
final_namount = 0; //final amount for night minutes
cout << "Please enter your account number: ";
cin >> account_number;
cout << "Please enter your service code (r or R for regular service and p or P for premium service): ";
cin >> service_code;
if (service_code == "r")
{
cout << "Please enter the amount of minutes used: " << minutes << endl;
}
if (minutes <= 50)
{
final_amount = 10;
cout << "Your final amount is $: " << final_amount << endl;
}
if (minutes > 50)
{
final_amount = (minutes * 0.20) + 10;
cout << "Your final amount is $: " << final_amount << endl;
}
else if (service_code == "p")
{
cout << "Please enter the amount of minutes used during the day: " << day_minutes << endl;
cout << "Please enter the amount of minutes used during the night: " << night_minutes << endl;
}
if (day_minutes <=75)
{
final_damount = 0;
final_amount = final_damount + final_namount + 20;
}
if (day_minutes > 75)
{
final_damount = day_minutes * 0.10;
final_amount = final_damount + final_namount + 20;
}
if (night_minutes <= 100)
{
final_namount = 0;
final_amount = final_damount + final_namount + 20;
}
if (night_minutes > 100)
{
final_namount = night_minutes * 0.05;
final_amount = final_damount + final_namount + 20;
cout << "Your final amount is: $ " << final_amount << endl;
}
else
cout << "Error, this program does not accept negative numbers.\n";
return 0;
}
Does anyone the problem to my program? Thank you.
In your code you never specify to ask for user input (read from any input streams or files), hence it doesn't ask for any input.
You will probably want to somewhere do something such as cin or cin.readline or any of several other various methods to read the user's input from stdin.
To avoid duplicating other questions I'm not putting further details here.
I'm writing a program in Microsoft Visual Studio with C++ that will retrieve information from a .txt file. In that file there are negative numbers, but when I try to write a while loop that states what to do if there is a negative number, I get several errors.
Can someone please help me with this? Here is my code and I do realize there are errors but I can't figure out how to write the While loop statement to read these values which are hours worked and the hourly rate from the .txt file
Sample text file:
45.0 10.50
-35.0 7.75
50.0 12.00
45.0 -8.50
30.0 6.50
48.0 -10.25
-50.0 10.00
50.0 8.75
40.0 12.75
56.0 8.50
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 <iomanip>
#include <fstream>
#include <iostream>
using namespace std;
float computeGross(float, float);
void computeTaxes(float, float&, float&, float&);
float computeNetPay (float&, float&, float&, float&);
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
ifstream inFile;
ofstream outFile;
int main()
{
inFile.open("employee.txt");
outFile.open("result.txt");
float hours, rate, grossPay, taxableIncome, fedTax, stTax, NetPay;
inFile >> hours >> rate;
while(inFile)
{
if {
(hours <= 0)&& (rate <= 0);
outFile << "Invalid Data";
}
else{
return 0;
}
}
grossPay = computeGross(hours, rate);
computeTaxes (grossPay, taxableIncome, fedTax, stTax);
computeNetPay (grossPay, fedTax, stTax, NetPay);
outFile << fixed << showpoint << setprecision(2);
outFile << "Hours worked = " << hours << endl
<< "Hourly rate = " << rate << endl
<< "Employee's gross pay = " << grossPay << endl
<< "Taxable Income = " << taxableIncome << endl
<< "Federal Taxes = " << fedTax << endl
<< "State Taxes = " << stTax << endl
<< "Net Pay = " << NetPay << endl;
return 0;
}
float computeGross (float h, float r) //Computes for the Gross Pay
{
if (h > hours)
return hours * r + (h - hours) * r * ovTime;
else
return h * r;
}
void computeTaxes(float g, float& taxable, float& fedTax, float& stTax) //Computes both Taxes
{
taxable = g - exemption;
if (taxable > 0.0)
{
fedTax = fedTaxRate * taxable;
stTax = stTaxRate * taxable;
}
else
{
fedTax = 0.0;
stTax = 0.0;
}
}
float computeNetPay (float& grossPay, float& fedTax, float& stTax, float& NetPay)
{
return NetPay = grossPay - fedTax - stTax;
}
In your main function you have:
while(inFile)
{
if ((hours <= 0) && (rate <= 0))
{
outFile << "Invalid Data";
}
else {
return 0;
}
}
When the else is triggered the program finishes, the main function returns. You might want a continue break or nothing here instead, that return statement ends the main function not the While loop.
To get all the data out of the file your read statement ( inFile >> hours >> rate);
will need to be in this or another loop. Say after the IF test for validity, it could be in the Else.
while(inFile)
{
if ((hours <= 0) && (rate <= 0)) {
outFile << "Invalid Data";
}
else {
// call the data functions
// save the returned values
}
//prime hours and rate for the next loop
inFile >> hours >> rate;
}
Well.. my guess is this is what your looking for:
Note that the:
if ((hours <= 0) && (rate <= 0))
is changed to:
if ((hours <= 0) || (rate <= 0))
otherwise it won't ever hit the "invalid data" with your supplied data
//*****************************
// 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 <iomanip>
#include <fstream>
#include <iostream>
using namespace std;
float computeGross(float, float);
void computeTaxes(float, float&, float&, float&);
float computeNetPay (float&, float&, float&, float&);
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 >> hours;
inFile >> rate;
if ((hours <= 0) || (rate <= 0))
{
outFile << "Invalid Data";
}
else
{
grossPay = computeGross(hours, rate);
computeTaxes (grossPay, taxableIncome, fedTax, stTax);
computeNetPay (grossPay, fedTax, stTax, NetPay);
outFile << fixed << showpoint << setprecision(2);
outFile << "Hours worked = " << hours << endl
<< "Hourly rate = " << rate << endl
<< "Employee's gross pay = " << grossPay << endl
<< "Taxable Income = " << taxableIncome << endl
<< "Federal Taxes = " << fedTax << endl
<< "State Taxes = " << stTax << endl
<< "Net Pay = " << NetPay << endl;
}
}
}
return 0;
}
The rest is the same
For a start, I think that this:
if {
(hours <= 0)&& (rate <= 0);
outFile << "Invalid Data";
}
Should be this:
if ((hours <= 0) && (rate <= 0)) {
outFile << "Invalid Data";
}
Note that to get code to format properly on StackOverflow, you should only use spaces, not tabs. I think that's whats causing your format issues.