Quantcast
Channel: if else issues
Viewing all articles
Browse latest Browse all 5

if else issues

0
0

I am having some isues with C++ if...else syntax and I can't seem to figure it out as I am not getting the desired results even though I feel that I have it all set. Here is my code;

<code>

#include "stdafx.h"
using namespace std;
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <iomanip>
#include <cmath>


 int filingStatus;
 double grossIncome;
 double taxesDue; 
 double noInput;


double calcTaxes(double grossIncome, int filingStatus)
{

if(filingStatus == 1)
{

 if (grossIncome >= 0 && grossIncome <= 8500)
     {
      taxesDue = grossIncome * (10 / 100);
       return taxesDue;
     }

 else if(grossIncome > 8500 && grossIncome <= 34500)
     {
      taxesDue = 850 + (15 / 100) * (grossIncome - 8500);
       return taxesDue;
     }

 else if(grossIncome > 34500 && grossIncome <= 83600)
    {
     taxesDue = (4750 + ((25 / 100) * (grossIncome - 34500)));
      return taxesDue;
    }

 else if(grossIncome > 83600 && grossIncome <= 174400)
    {
     taxesDue = (17025 + ((28 / 100) * (grossIncome - 83600)));
      return taxesDue;
    }

 else if(grossIncome > 174400 && grossIncome <= 379150)
    {
     taxesDue = (42449 + ((33 / 100) * (grossIncome - 174400)));
      return taxesDue;
    }

 else
    {
     taxesDue = (110016.50 + ((35 / 100) * (grossIncome - 379150)));
      return taxesDue;
    }

}//end if

}//End calcTaxes


int main()
{
 cout << "Please enter your gross income: ";
 cin >> grossIncome;

 cout << "Please enter your filing status\n(For Single enter 1, \nfor Married Filing Jointly or Qualifying Widow(er) enter 2, \nfor Married Filing Separately enter 3, \nand for Head of Household enter 4): " << endl;
 cin >> filingStatus;

 calcTaxes(grossIncome, filingStatus);
 cout << "Your taxes due for the last fiscal year is " << taxesDue;
 system("pause");

}//end main


</code>

Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images