Invalid Operands of types int and double to binary operator

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fred jackson
    New Member
    • Nov 2011
    • 1

    Invalid Operands of types int and double to binary operator

    Code:
    #include <iostream>                                                             //for I/O                                                            
    #include <iomanip>                                                              //for formatting output                                          
    #include <cmath>                                                                //for called math functions
    #include <cctype>                                                               //for upper/lower case
    using namespace std;
    
        //Global Constants
        const double SAVINGS_PER_EXEMPTION = 3650.0;                                 //Deduction per exemption                      
        const double SINGLE_INCOME_LIMIT = 166800.0;                                //Single Income Limit
        const double MARRIED_JOINT_LIMIT = 250200.0;                                //Married Joint Limit 
        const double MARRIED_SEPARATE_LIMIT = 125100.0;                             //Married Separate Limit
        const double HEAD_HOUSEHOLD_LIMIT = 208500.0;                               //Head of Household Limit
        const double MINIMUM_SAVINGS_PER_EXEMPTION = 2433.0;
        const int NEGATIVE_ERROR = -1; 
        const double EXEMPTION_AMOUNT_ONE = 2500.0;
    
    
    int main()
    {
                                     
    //Local Variables
        double Adjusted_Gross_Income = 0.0;                                         //Adjusted gross income input by user                                
        int Total_Exemptions_Claimed = 0;                                           //Number of exemptions input by user
        double Exemptions_Claimed_Savings = 0.0;                                    //Calculation of deductions for exemptions
        int Filing_Status = 0;
        double Amount_Over_Limit_One = 0.0;
        double Amount_Over_Limit_Two = 0.0;
        double Amount_Over_Limit_Three = 0.0;
        double Amount_Over_Limit_Four = 0.0;
        double Amount_Over_Limit_Five = 0.0;
        double Miniumum_Exemptions_Claimed_Savings = 0.0;
        double Divison_Result_One = 0.0;
        double Divison_Result_Two = 0.0;
        double Divison_Result_Three = 0.0;
        double Divison_Result_Four = 0.0;
        double Divison_Result_Five = 0.0;
        
        //Read input from user
        cout << "Enter the number of exemptions claimed: ";
        cin >> Total_Exemptions_Claimed;
        cout <<endl;
        
        cout << "Enter your Adjusted Gross Income (1040, line 38): ";
        cin >> Adjusted_Gross_Income;
        cout <<endl;
        
        cout <<"1 - Single" <<endl;
        cout <<"2 - Married, Filing Jointly" <<endl;
        cout <<"3 - Head of Household" <<endl;
        cout <<"4 - Qualifying Widow(er)" <<endl;
        cout <<"5 - Married, Filing Separately" <<endl;
        cout <<"Enter your filing status from above (1-5): ";
        cin >> Filing_Status;
        cout <<endl;
        
       //LINE 1 Calculations
       
       //LINE 2 Calculations
       Exemptions_Claimed_Savings = SAVINGS_PER_EXEMPTION * Total_Exemptions_Claimed;
       cout <<"2.  Exemptions claimed (" <<Total_Exemptions_Claimed <<" x 3650): " << setw(8) << Exemptions_Claimed_Savings <<endl;
       
       //LINE 3 Calculations
       cout <<"3.  Adjusted gross income: " << setw (8) <<Adjusted_Gross_Income <<endl;
       
       //Line 4 Calculations
         if (Filing_Status == 1)
           cout <<"4.  Filing status limit (single):" <<setw(10) <<SINGLE_INCOME_LIMIT;
        else if (Filing_Status == 2)
           cout <<"4.  Filing status limit (Married filing joint:" <<setw(10) <<MARRIED_JOINT_LIMIT;
        else if (Filing_Status == 3)
           cout <<"4.  Filing status limit (Head of household):" <<setw(10) <<HEAD_HOUSEHOLD_LIMIT;
        else if (Filing_Status == 4)
           cout <<"4.  Filing status limit (Qualifying Widow(er):" <<setw(10) <<MARRIED_JOINT_LIMIT;   
        else if (Filing_Status == 5)
           cout <<"4.  Filing status limit (Married filing separately):" <<setw(10) <<MARRIED_SEPARATE_LIMIT;
    
       //Line 5 Calculations
        if (Filing_Status == 1)
        {
             Amount_Over_Limit_One = Adjusted_Gross_Income - SINGLE_INCOME_LIMIT;
             cout <<endl <<"5.  AGI amount over limit:"  <<setw(10) <<Amount_Over_Limit_One <<endl;
        }
    
        else if (Filing_Status == 2)
        {
            Amount_Over_Limit_Two = Adjusted_Gross_Income - MARRIED_JOINT_LIMIT;
            cout <<endl <<"5.  AGI amount over limit:"  <<setw(10) <<Amount_Over_Limit_Two <<endl;
        }
    
       else if (Filing_Status == 3)
        {
            Amount_Over_Limit_Three = Adjusted_Gross_Income - HEAD_HOUSEHOLD_LIMIT;
            cout <<endl <<"5.  AGI amount over limit:"  <<setw(10) <<Amount_Over_Limit_Three <<endl;
        }
       else if (Filing_Status == 4)
        {
            Amount_Over_Limit_Four = Adjusted_Gross_Income - MARRIED_JOINT_LIMIT;
            cout <<endl <<"5.  AGI amount over limit:"  <<setw(10) <<Amount_Over_Limit_Four <<endl;
        }
       else if (Filing_Status == 5)
        {
            Amount_Over_Limit_Five = Adjusted_Gross_Income - MARRIED_SEPARATE_LIMIT;
            cout <<endl <<"5.  AGI amount over limit:"  <<setw(10) <<Amount_Over_Limit_Five <<endl;
        }
       
       //Line 6 Calculations
       if (Filing_Status == 5 && Amount_Over_Limit_Five > 61,250)
        {
    	    Miniumum_Exemptions_Claimed_Savings = MINIMUM_SAVINGS_PER_EXEMPTION * Total_Exemptions_Claimed;
            cout  <<"6. Excemptions allowed (" <<Total_Exemptions_Claimed <<" x 2433): " << setw(8) << Miniumum_Exemptions_Claimed_Savings <<endl <<endl;
            cout <<"***Enter amount from worksheet line 6 on form 1040 line 42";
            system ("pause");
            return NEGATIVE_ERROR;     
        }
       else if (Filing_Status = 1 && Amount_Over_Limit_One > 122,500) 
        {
            Miniumum_Exemptions_Claimed_Savings = MINIMUM_SAVINGS_PER_EXEMPTION * Total_Exemptions_Claimed;
            cout  <<"6. Excemptions allowed (" <<Total_Exemptions_Claimed <<" x 2433): " << setw(8) << Miniumum_Exemptions_Claimed_Savings <<endl <<endl;
            cout <<"***Enter amount from worksheet line 6 on form 1040 line 42";
            system ("pause");
            return NEGATIVE_ERROR;
        }
        else if (Filing_Status = 2 && Amount_Over_Limit_Two > 122,500) 
        {
            Miniumum_Exemptions_Claimed_Savings = MINIMUM_SAVINGS_PER_EXEMPTION * Total_Exemptions_Claimed;
            cout  <<"6. Excemptions allowed (" <<Total_Exemptions_Claimed <<" x 2433): " << setw(8) << Miniumum_Exemptions_Claimed_Savings <<endl <<endl;
            cout <<"***Enter amount from worksheet line 6 on form 1040 line 42";
            system ("pause");
            return NEGATIVE_ERROR;
        }
        else if (Filing_Status = 3 && Amount_Over_Limit_Three > 122,500) 
        {
            Miniumum_Exemptions_Claimed_Savings = MINIMUM_SAVINGS_PER_EXEMPTION * Total_Exemptions_Claimed;
            cout  <<"6. Excemptions allowed (" <<Total_Exemptions_Claimed <<" x 2433): " << setw(8) << Miniumum_Exemptions_Claimed_Savings <<endl <<endl;
            cout <<"***Enter amount from worksheet line 6 on form 1040 line 42";
            system ("pause");
            return NEGATIVE_ERROR;
        }
        else if (Filing_Status = 4 && Amount_Over_Limit_Four > 122,500) 
        {
            Miniumum_Exemptions_Claimed_Savings = MINIMUM_SAVINGS_PER_EXEMPTION * Total_Exemptions_Claimed;
            cout  <<"6. Excemptions allowed (" <<Total_Exemptions_Claimed <<" x 2433): " << setw(8) << Miniumum_Exemptions_Claimed_Savings <<endl <<endl;
            cout <<"***Enter amount from worksheet line 6 on form 1040 line 42";
            system ("pause");
            return NEGATIVE_ERROR;
        }
    
     if (Filing_Status == 1)
        {
    	    Divison_Result_One = Amount_Over_Limit_One / EXEMPTION_AMOUNT_ONE;
            cout  <<"6. Division result:" <<setw(10 <<Divison_Result_One <<endl;
        }
        else if (Filing_Status == 2)
        {
    	Divison_Result_Two = Amount_Over_Limit_One / 2500.0;
            cout  <<"6. Division result:" <<setw(10 <<Divison_Result_Two <<endl;   
    }
       
       
    cout << endl << endl;
        system ("PAUSE");
        return 0;
    }
    -------------------

    Frustrated
    Last edited by Banfa; Nov 14 '11, 10:16 AM. Reason: Added code tags and you are not nearly as frustrated as I am at having people post code "with a problem" without explaining what the code was meant to do and what problem is occurring that p
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You are missing a ) in this code:

    Code:
    cout  <<"6. Division result:" <<setw(10 <<Divison_Result_One <<endl;
    It should be:

    Code:
    cout  <<"6. Division result:" <<setw(10) <<Divison_Result_One <<endl;
    This error is in more than one place.

    Comment

    Working...