if salary < 3500 then tax = 0
if salary is between 3500-8000 then tax is 6% of amount over 3500 + $105
if salary is between 8000-20000 then tax is 11% of amount over 8000 + $375
if salary is between 20000-34000 then tax is 17% of amount over 20000 + $1695
if salary is between 34000-52000 then tax is 24% of amount over 34000 + $4075
if salary is over 52000 then tax is 32% of amount over 52000 + $8395
the program must print to output like so:ex:
this program will calculate the user's tax liabilities
========================================================
name hours pay rate salary tax
========================================================
fred rubbles 2256 12.75 28764.00 6584.88
donald duck *********hours invalid*************
HERE IS WHAT CODE IVE DONE BUT IT ISNT WORKING i've been working on this for weeks and the assignment is now almost due and i cannot fix it PLEASE help thank you!!!
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
void main (void)
{
/*****Declare Variables*****/
ifstream fin;
ofstream fout;
int hours, counter, num;
float pay_rate, tax;
double avg_sal, total_sal;
string dataf_name, name, dataf_out;
/**********Input***********/
cout<< "Enter input file name:";
getline(cin,dataf_name);
cout<< "Enter output file name:";
getline(cin,dataf_out);
//cin>>dataf_out;
fin.open (dataf_name.c_str());
if (fin.fail())
cout<< "Bad file name!";
else
{
fout.open("out.txt");
cout<<setprecision(2);
fout<<setprecision(2);
cout<<\t"This pogram will calculate and report user's tax liabilities."<<endl;
cout<<\t"===================================================="<<endl;
cout<<\t"Name"<<endl<<name;
cout<<setw(10)<<"Hours"<<endl<<hours;
cout<<setw(20)<<"Pay Rate"<<endl<<pay_rate;
cout<<setw(30)<<"Salary"<<endl<<salary;
cout<<setw(40)<<"Tax"<<tax<<endl;
cout<<\t"===================================================="<<endl;
getline(fp, name);
while (fp) // while (!fp.eof))
{
fin>>hours;
fin>>pay_rate;
if hours < 0
cout<<"Invalid hours";
if pay_rate < 0
cout<<"Invlaid pay rate";
else
salary = pay_rate * hours;
if salary < 3500
tax = 0;
else if salary < 8000
tax = [((salary - 3500)*.06)+ 105];
else if salary < 20000
tax = [((salary - 8000)*.11)+ 375];
else if salary < 34000
tax = [((salary - 20000)*.17+ 1695];
else if salary < 52000
tax = [((salary - 34000)*.24+ 4075];
else if salary > 52000
tax = [((salary - 52000)*.32+ 8395];
infile>>name;
while(infile)
{
counter = 0;
sum = 0;
infile>>num;
while (infile)
{
total_sal = total_sal + num;
salary++;
infile>> num;
}
avg_sal= total_sal/num;
/**********output********/
cout<<\t"Average Gross Salary:"\s\s<<avg_sal<<endl;
}

New Topic/Question
Reply



MultiQuote



|