SOLVED
I've been working on this project for a few hours now, and I've got the algorithm part of it down, however, I've been having 8 errors, all caused by "missing semicolons" supposedly. I cannot for the life of me find the problem/error however. Here is my following code (its not huge, less then 150 lines about). Opinions are welcome and I am still an amateur.
Code:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
// The purpose of this program is to calculate United State's personal income tax based
// on filing status and taxable income.
// Filing Statuses
// 0 = Single Filer
// 1 = Married Filing Jointly
// 2 = Married Filing Seperately
// 3 = Head of Household
ifstream inFile; // Input stream
int SSN, filingStatus; //used SSN as variable for simplicity and popularness.
float taxableIncome; // Taxable Income (total income before tax)
string firstName, middleName, lastName; // strings for each part of the name
string fullName = firstName + middleName + lastName; // Just to make it simple.
float computeSingle(float);
float computeMjoint(float);
float computeMseperate(float);
float computeHeadhouse(float);
// All float integers in the above formulas are for taxableIncome. These formula's compute the tax.
int main()
{
inFile.open("taxData.txt"); //opens stream for input.
if (!inFile) // Small if statement to check for file stream status.
{
cout << "File could not be opened or found" << endl;
return 0;
}
inFile >> firstName >> middleName >> lastName >> SSN >> filingStatus >> taxableIncome; //Getting input in order.
cout << fixed << showpoint << setprecision(2);
if(filingStatus = 0){
cout << "Full Name = " << fullName << endl
<< "SSN = " << SSN << endl
<< "Filing Status = " << filingStatus << endl
<< "Computed Tax = " << computeSingle(taxableIncome) << endl;
}
else if(filingStatus = 1){
cout << "Full Name = " << fullName << endl
<< "SSN = " << SSN << endl
<< "Filing Status = " << filingStatus << endl
<< "Computed Tax = " << computeMjoint(taxableIncome) << endl;
}
else if(filingStatus = 2){
cout << "Full Name = " << fullName << endl
<< "SSN = " << SSN << endl
<< "Filing Status = " << filingStatus << endl
<< "Computed Tax = " << computeMseperate(taxableIncome) << endl;
}
else if(filingStatus = 3){
cout << "Full Name = " << fullName << endl
<< "SSN = " << SSN << endl
<< "Filing Status = " << filingStatus << endl
<< "Computed Tax = " << computeHeadhouse(taxableIncome) << endl;
}
return 0;
}
float computeSingle(float i)
{
if (i <= 6000)
return i * .10;
else if (i <= 27950)
return (i - 6000) * .15 + 6000 * .10;
else if (i <= 67700)
return (i - 27950) * .27 + 27950 * .15 + 6000 * .10;
else if (i <= 141250)
return (i - 67700) * .30 + 67700 * .27 + 27950 * .15 + 6000 * .10;
else if (i <= 307050)
return (i - 141250) * .35 + 141250 * .30 + 67700 * .27 + 27950 * .15 + 6000 * .10;
else if (i >= 307051)
return (i - 307051) * .386 + 307050 8 .35 + 141250 * .30 + 67700 * .27 + 27950 * .15 + 6000 * .10;
return 0;
}
float computeMjoint(float i)
{
if (i <= 12000)
return i * .10;
else if (i <= 46700)
return (i - 12000) * .15 + 12000 * .10;
else if (i <= 112850)
return (i - 46700) * .27 + 46700 * .15 + 12000 * .10;
else if (i <= 171950)
return (i - 112850) * .30 + 112850 * .27 + 46700 * .15 + 12000 * .10;
else if (i <= 307050)
return (i - 171950) * .35 + 171950 * .30 + 112850 * .27 + 46700 * .15 + 12000 * .10;
else if (i >= 307051)
return (i - 307051) * .386 + 307050 8 .35 + 171950 * .30 + 112850 * .27 + 46700 * .15 + 12000 * .10;
return 0;
}
float computeMseperate(float i)
{
if (i <= 6000)
return i * .10;
else if (i <= 23250)
return (i - 6000) * .15 + 6000 * .10;
else if (i <= 56425)
return (i - 23350) * .27 + 23350 * .15 + 6000 * .10;
else if (i <= 85975)
return (i - 56425) * .30 + 56425 * .27 + 23350 * .15 + 6000 * .10;
else if (i <= 153525)
return (i - 85975) * .35 + 85975 * .30 + 56425 * .27 + 23350 * .15 + 6000 * .10;
else if (i >= 153526)
return (i - 153526) * .386 + 153525 8 .35 + 85975 * .30 + 56425 * .27 + 23350 * .15 + 6000 * .10;
return 0;
}
float computeHeadhouse(float i)
{
if (i <= 10000)
return i * .10;
else if (i <= 37450)
return (i - 10000) * .15 + 10000 * .10;
else if (i <= 96700)
return (i - 37450) * .27 + 37450 * .15 + 10000 * .10;
else if (i <= 156700)
return (i - 96700) * .30 + 96700 * .27 + 37450 * .15 + 10000 * .10;
else if (i <= 307050)
return (i - 156700) * .35 + 156700 * .30 + 96700 * .27 + 37450 * .15 + 10000 * .10;
else if (i >= 307051)
return (i - 307051) * .386 + 307050 8 .35 + 156700 * .30 + 96700 * .27 + 37450 * .15 + 10000 * .10;
return 0;
}
and here are the errors. They are based in the sub formulas (computeSingle, etc). Each one of these errors appears twice in the output log. I am using Visual Studio 2008.
(90) : error C2143: syntax error : missing ';' before 'constant'
(112) : error C2143: syntax error : missing ';' before 'constant'
(135) : error C2143: syntax error : missing ';' before 'constant'
(158) : error C2143: syntax error : missing ';' before 'constant'
Any help is greatly appreciated. I've been looking for an hour or so now and I figured it would be best to get a different perspective.