Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE IN C++ 6.21 LAB*: Program: Income tax form - functions Program Specifications Write a program to calculate U.S. income tax owed given wages, taxable

PLEASE IN C++

6.21 LAB*: Program: Income tax form - functions

Program Specifications Write a program to calculate U.S. income tax owed given wages, taxable interest, unemployment compensation, status (dependent, single, or married), and taxes withheld. Dollar amounts are displayed as integers without comma separators. For example, cout << "Deduction: $" << deduction << endl; Note: this program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. Step 1. Within main() input wages, taxable interest, unemployment compensation, status (0=dependent, 1=single, and 2=married), and taxes withheld as integers.

Step 2 (2 pts). Complete the CalcAGI() function. Calculate the adjusted gross income (AGI) that is the sum of wages, interest, and unemployment. Convert any negative values to positive before summing to correct potential input errors. Return the AGI. Note the provided code in main() calls CalcAGI() and outputs the returned value. Submit for grading to confirm two tests pass. Ex: If the input is:

20000 23 500 1 400 

The output is:

AGI: $20523 

Step 3 (2 pts). Complete the GetDeduction() function. Return the deduction amount based on status: (0) dependent = 6000, (1) single = 12000, or (2) married=24000. Return 6000 if the status is anything but 0, 1, or 2. Within main() call GetDeduction() and output the returned value. Submit for grading to confirm four tests pass. Ex: If the input is:

20000 23 500 1 400 

The additional output is:

AGI: $20523 Deduction: $12000 

Step 4 (2 pts). Complete the CalcTaxable() function. Calculate taxable amount (AGI - deduction). Set taxable to zero if calculation results in negative value. Return taxable value. Within main() call CalcTaxable() and output the returned value. Submit for grading to confirm six tests pass. Ex: If the input is:

20000 23 500 1 400 

The additional output is:

AGI: $20523 Deduction: $12000 Taxable income: $8523 

Step 5 (2 pts). Complete the CalcTax() function. Calculate tax amount based on status and taxable income (see tables below). Tax amount should be stored initially as a double, rounded to the nearest whole number using round(), and converted to an integer before returning. Within main() call CalcTax() and output the returned value. Submit for grading to confirm eight tests pass. Ex: If the input is:

50000 0 0 2 5000 

The additional output is:

AGI: $50000 Deduction: $24000 Taxable income: $26000 Federal tax: $2720 
Income Tax for Dependent or Single Filers
$0 - $10000 10% of the income
$10001 - $40000 $1000 + 12% of the amount over $10000
$40001 - $85000 $4600 + 22% of the amount over $40000
over $85000 $14500 + 24% of the amount over $85000
Income Tax for Married Filers
$0 - $20000 10% of the income
$20001 - $80000 $2000 + 12% of the amount over $20000
over $80000 $9200 + 22% of the amount over $80000

Step 6 (2 pts). Complete the CalcTaxDue() function. Set withheld parameter to zero if negative to correct potential input error. Calculate and return amount of tax due (tax - withheld). Within main() call CalcTaxDue() and output returned value. Submit for grading to confirm all tests pass. Ex: If the input is:

80000 0 500 2 12000 

The additional output is:

AGI: $80500 Deduction: $24000 Taxable income: $56500 Federal tax: $6380 Tax due: $-5620 

COMPLETE CODE

#include

#include

using namespace std;

// Calculates Adjusted Gross Income (AGI) based on wages, interest, and unemployment income

int CalcAGI(int wages, int interest, int unemployment) {

int agi = wages + interest + unemployment;

if (agi < 0) {

agi = abs(agi); // If AGI is negative, make it positive

}

return agi;

}

// Determines standard deduction based on filing status

int GetDeduction(int status) {

int deduction = 0;

switch(status) { // Check filing status

case 0: // Dependent

deduction = 6000;

break;

case 1: // Single

deduction = 12000;

break;

case 2: // Married

deduction = 24000;

break;

default: // Default to single

deduction = 12000;

break;

}

return deduction;

}

// Calculates taxable income based on AGI and standard deduction

int CalcTaxable(int agi, int deduction) {

int taxable = agi - deduction;

if (taxable < 0) {

taxable = 0; // If taxable income is negative, set it to 0

}

return taxable;

}

// Calculates federal income tax based on filing status and taxable income

int CalcTax(int status, int taxable) {

double tax = 0;

if (status == 0 || status == 1) { // Dependent or single

if (taxable <= 10000) {

tax = taxable * 0.1;

} else if (taxable > 10000 && taxable <= 40000) {

tax = 1000 + (taxable - 10000) * 0.12;

} else if (taxable > 40000 && taxable <= 85000) {

tax = 4600 + (taxable - 40000) * 0.22;

} else if (taxable > 85000) {

tax = 14500 + (taxable - 85000) * 0.24;

}

} else if (status == 2) { // Married

if (taxable <= 20000) {

tax = taxable * 0.1;

} else if (taxable > 20000 && taxable <= 80000) {

tax = 2000 + (taxable - 20000) * 0.12;

} else if (taxable > 80000) {

tax = 9200 + (taxable - 80000) * 0.22;

}

}

int taxRounded = round(tax); // Round tax to nearest whole number

return taxRounded;

}

// Calculates tax due based on federal tax and tax already withheld

int CalcTaxDue(int tax, int withheld) {

if (withheld < 0) {

withheld = 0; // If tax already withheld is negative, set it to 0

}

int taxDue = tax - withheld;

return taxDue;

}

int main() {

int wages, interest, unemployment, status, withheld;

cin >> wages >> interest >> unemployment >> status >> withheld;

int agi = CalcAGI(wages, interest, unemployment);

cout << "AGI: $" << agi << endl;

int deduction = GetDeduction(status);

cout << "Deduction: $" << deduction << endl;

int taxable = CalcTaxable(agi, deduction);

cout << "Taxable income: $" << taxable << endl;

int tax = CalcTax(status, taxable);

cout << "Federal tax: $" << tax << endl;

int taxDue = CalcTaxDue(tax, withheld);

cout << "Tax due: $" << taxDue << endl;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions