I have to create this C++ program for a class could someone please explain this more in detail for me

Create a new C++ workspace called incomeTax. Construct a C++ program with a
function called incomeTax which computes the tax due using the gross income and itemized
deduction.
• The taxpayer's deduction is either the standard deduction (4,150) or the itemized
deduction, whichever is larger.
• Taxable income is determined by subtracting the taxpayer’s deduction from the
taxpayer's gross income; if the taxable income is less than 0, then the taxable
income is 0.
• Total tax is determined by multiplying the taxable income by the tax rate (0.17).
Your main function should prompt the user for his/her gross income and itemized deduction, and
then use your incomeTax function to compute the total tax due. Finally, print out the tax due.

3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by rbduck09

Well, I can help to make the description more concrete:

gross income: Would be a number (int, float or double) that the user is asked for and will enter.

itemized deduction: Would be an array of numbers (int, float or double) each representing a tax deduction amount.

The taxpayer's deduction is either the standard deduction (4,150) or the itemized
deduction, whichever is larger: This means you would need to take the sum of all the deductions (sum of the array elements), then take the maximum number between 4150 and the total of the deductions.

Taxable income is determined by subtracting the taxpayer’s deduction: Take the gross income and subtract the value found at the previous step. Then, set the taxable income to the maximum number between 0 and the result of the subtraction.

Total tax is determined by multiplying the taxable income by the tax rate (0.17): Multiply the number you got in the previous step by 0.17 to obtain the taxes to be paid. That number should be the output of your incomeTax function.

Finally, in main(), you first ask the user for the gross income, then for the list of deductions, call the incomeTax function with these two parameters (income and array of deductions), and finally, print out the result of the function (i.e. the tax to be paid).

If you want any further help, you will have to show some progress towards implementing the above in C++ (i.e. some code). We are not going to do that for you.

nvm guy above got it right on

Edited by AutoPython: n/a

Thanks I just needed it explained more in detail for me ... The way that it was written I just didn't understand it

I have a question about my code

//...
// global constants ...
const int STD_DEDUCT = 4150; // dollars
const double TAX_RATE = 0.17; // of total net income

double incomeTax();
{
int grossIncome = getValidInt( "Enter gross income in dollars: " );
int totDeduct = getTotDeduct();
if( STD_DEDUCT > totDeduct ) totDeduct = STD_DEDUCT;
if( totDeduct >= grossIncome ) return 0.0;
// else...
return ( grossIncome - totDeduct ) * TAX_RATE;
}

Can someone tell me if this totally wrong or tell me whats wrong with my code ( I'm not asking for you to solve it )

It seems about right to me. I don't know about your getValidInt and getTotDeduct, but if they work, than this should work. Have you tried compiling and running?

Ignore the last piece of code written!! Can somebody tell me if this is right so far or am I totally off

``````#include <iostream>
using namespace std;

const int SUM_OF_DEDUCT = 4150; // dollars
const double TAX_RATE = 0.17; // of total net income

int incomeTax (int income, int arrayofdeduct)
{
float grossIncome;
int SUM_OF_DEDUCT;
int TOT_DEDUCT;
if( SUM_OF_DEDUCT > TOT_DEDUCT ) TOT_DEDUCT = SUM_OF_DEDUCT;
if( TOT_DEDUCT >= grossIncome ) return 0.0;
// else....
return ( grossIncome - TOT_DEDUCT) * TAX_RATE;

return (income);
}

int main ()
{
int income;
int deduction;
cout << "Please enter you gross income: ";
cin >> income;
cout << "Please enter you itemized deduction: ";
cin >> deduction;

return 0;
}``````

How do I call my first function in the code into the main function when after I ask the user for their gross income and deductions?

Edited by rbduck09: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.