Thread: Small Error it seems.

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    4

    Small Error it seems. *SOLVED*

    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.
    Last edited by zerkz; 03-24-2009 at 03:18 PM. Reason: problem was solved.

  2. #2
    Registered User
    Join Date
    May 2008
    Posts
    15
    This doesn't do what you think:
    Code:
    filingStatus = 0
    You need to use "==" to do a comparison.

    Your semicolon errors are caused by the 8 that was most likely supposed to by a '*':
    Code:
    return (i - 307051) * .386 + 307050 8 .35 + 171950 * .30 + 112850 * .27 + 46700 * .15 + 12000 * .10;

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    4
    Quote Originally Posted by rt454 View Post
    This doesn't do what you think:
    Code:
    filingStatus = 0
    You need to use "==" to do a comparison.

    Your semicolon errors are caused by the 8 that was most likely supposed to by a '*':
    Code:
    return (i - 307051) * .386 + 307050 8 .35 + 171950 * .30 + 112850 * .27 + 46700 * .15 + 12000 * .10;
    Thank you greatly for your input. My left shift key sticks all the time (I had to buy a cheap 20$ keyboard after my g15 blew up)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to split long programe in small files
    By umeshjaviya in forum C Programming
    Replies: 11
    Last Post: 04-15-2008, 02:45 AM
  2. Small executables in VC++ 8
    By Bleech in forum Windows Programming
    Replies: 3
    Last Post: 06-20-2007, 08:28 AM
  3. want to make this small program...
    By psycho88 in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2005, 02:05 AM
  4. FILES in WinAPI
    By Garfield in forum Windows Programming
    Replies: 46
    Last Post: 10-02-2003, 06:51 PM
  5. yhatzee, small straight
    By uglyjack in forum C++ Programming
    Replies: 2
    Last Post: 06-13-2002, 03:09 AM