Code:
//adds the iostream library to the program
#include <iostream>
//adds the iomanip library to the program
#include <iomanip>
//adds the math library to the program
#include <math.h>
That last one should be <cmath>, and the include statements don't add the libraries to the program, they only make the function prototypes available to the compiler for those functions mentioned in the headers so that the compiler can do its job typechecking any function arguments and return values. It is the linkers job to bring the relevant library code for those actual functions that you use into the program.
Technically you should have included <cstdlib> for the system function. However, you should replace that with a couple calls to the cin.get() function.
Code:
if (Income <= 5000)
{
tax = 0;
cout << "You have entered an income of $"<< Income << endl;
cout << "The income tax owed is $"<< NEWI<< endl;
}
else if (Income <=10000)
{
tax = 3;
cout << "You have entered an income of $"<< Income << endl;
cout << "The income tax owed is $"<< NEWI<< endl;
}
else if (Income <=20000)
{
tax = 5.5;
cout << "You have entered an income of $"<< Income << endl;
cout << "The income tax owed is $"<< NEWI<< endl;
}
else if (Income <=40000)
{
tax = 10.8;
cout << "You have entered an income of $"<< Income << endl;
cout << "The income tax owed is $"<< NEWI<< endl;
}
else
{
tax = 23.7;
cout << "You have entered an income of $"<< Income << endl;
cout << "The income tax owed is $"<< NEWI<< endl;
}
This way of testing the level of income is fine, you shouldn't need to do it the other way that was suggested. The real problem is that you aren't calling your GetIncome function anywhere:
Code:
// The following cout was common to all blocks of code below so I moved it out here
cout << "You have entered an income of $"<< Income << endl;
if (Income <= 5000)
{
tax = 0;
cout << "The income tax owed is $"<< GetIncome(Income,tax) << endl;
}
else if (Income <=10000)
{
tax = 3;
cout << "The income tax owed is $"<< GetIncome(Income,tax) << endl;
}
else if (Income <=20000)
{
tax = 5.5;
cout << "The income tax owed is $"<< GetIncome(Income,tax) << endl;
}
else if (Income <=40000)
{
tax = 10.8;
cout << "The income tax owed is $"<< GetIncome(Income,tax) << endl;
}
else
{
tax = 23.7;
cout << "The income tax owed is $"<< GetIncome(Income,tax) << endl;
}
The above way of doing things also eliminates the need for the NEWI variable in the main function. One other thing to mention, calling the function GetIncome seems a bit misleading, it seems it should be called GetTax instead.