I normally don\'t do this but I feel like it is more important to spend time wit
ID: 3535241 • Letter: I
Question
I normally don't do this but I feel like it is more important to spend time with my dying grandmother (who pretty much raised me) who is in the hospital being eaten alive from breast cancer. They don't give her long to live and I want to spend her last days with her. I have 3,000 pts to give to the person who helps me.
Thank you,
Tom
Instructions:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please modify the tax.cpp file with the below upgrades (upgrades are labeled toward the end of this posting).
tax.cpp file:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Upgrades:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Note: the do/while loop in the area labeled MAIN LOOP in the tax.cpp file should have been a while statement instead. Also the confirmations code for each input is no longer needed and needs to be removed. Please start by correcting these and continue below. Thanks.
The primary objective of the solution remains to compute federal personal income taxes. The solution can have NO global variables. The tax liability depends on how much money one makes as well as their filing status. For our purposes we will use four filing statuses. These are (1)single filers, (2)married filing jointly, (3)married filing separately, and (4)head of household.
Tax Rate
Single Filers
Married Filing Jointly
Married Filing Separately
Head of Household
10%
Up to $7,550
Up to $15,100
Up to $7,550
Up to $10,750
15%
$7,551-$30,650
$15,101-$61,300
$7,551-$30,650
$10,751-$41,050
25%
$30,651-$74,200
$61,301-$123,700
$30,651-$61,850
$41,051-$106,000
28%
$74,201-$154,800
$123,701-$188,450
$61,851-$94,225
$106,001-$171,650
33%
$154,801-$336,550
$188,451-$336,550
$94,226-$168,275
$171,651-$336,550
35%
$336,551 or more
$336,551 or more
$168,276 or more
$336,551 or more
For each filing status there are six tax rates. Each rate is applied to a given amount of the taxable income. For example, for a taxable income of $450,000 for a single filer, $7,550 is taxed at 10%, ($30,650-$7,550) at 15%, ($74,200-$30,650) at 25%, ($154,800-$74,200) at 28%, ($336,550-$154,800) at 33%, and ($450,000-336,550) at 35%.
The six tax rates are to be stored in a one-dimensional array with data type float. The four filing status descriptions are to be stored in a one-dimensional array of data type string..
Variables
Name
Type
Description and edit specifications
statusCode
int
Status code must be from 1 to 4. 1=single, 2=married filing jointly, 3=married filing separately, 4= head of household, 9 = end processing.
taxableIncome
float
Taxable income is entered by the user from the keyboard. The amount must be numeric and not less than $500.
taxAmt
float
taxAmt is a calculated field and is determined from the supplied tax table as applied to the taxableIncome.
taxRate[6]
float
6 tax rates with amounts specified in the above table.
filingStatus[4]
string
4 filing status descriptions as shown in the above table.
Your program should be modular and contain at least 4 user defined functions beyond the main() function. You are to follow these specifications as closely as possible. You should have functions that do the following:
Functions
Description and specifications
main()
main() should be concise and drive the execution of the solution. The primary loop should be a while loop that repeats the steps necessary to display the results until the user enters a status code of 9 that will terminate the job.
getStatusCode
This function is to input the filing status code. This is to be a return by value function. You should use a do/while loop to control the input logic. You are to keep the user in the loop until the input is correct. You are to ensure that the status codes are as specified above.
.
getTaxIncome
This function is to input taxable income and is a return by value function. You are to use a do/while loop for this logic. You are to keep the user in the loop until the input is valid.
calcTaxAmt
This function is to calculate the taxAmt as determined by statusCode and taxableIncome. This is a return by value function.
displayResults
The role of this function is to display the program’s results. You are to display the filing status description, the taxable income, and the tax amount. Your report should use proper formatting. This is a void function.
Hint: As you can see the tax rates are the same for each of the filing statuses. The primary differences in all the status groups are the range amounts for the applicable tax rates. The following is an example of calculations and resulting output with a taxable income of $70,000 and a married filing jointly filing status. (There is also an Excel spreadsheet supplied that provides details of calculations for each appropriate tax bracket.) You may experience minor differences between some examples and your program due to computational rounding and truncation.
Taxable Income: $70000, Filing status of Married Filing Jointly
Display of above
Filing status: Married Filing Jointly
Taxable income: $70000.00
Tax amount: $10615.00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thank you,
Tom
Tax Rate
Single Filers
Married Filing Jointly
Married Filing Separately
Head of Household
10%
Up to $7,550
Up to $15,100
Up to $7,550
Up to $10,750
15%
$7,551-$30,650
$15,101-$61,300
$7,551-$30,650
$10,751-$41,050
25%
$30,651-$74,200
$61,301-$123,700
$30,651-$61,850
$41,051-$106,000
28%
$74,201-$154,800
$123,701-$188,450
$61,851-$94,225
$106,001-$171,650
33%
$154,801-$336,550
$188,451-$336,550
$94,226-$168,275
$171,651-$336,550
35%
$336,551 or more
$336,551 or more
$168,276 or more
$336,551 or more
Explanation / Answer
#include<iostream.h>
#include<iomanip.h>
#include<string.h>
//using namespace std;
//using std::cout; // Added so that cout won't be ambiguous.
//using std::cin; // Added so that cin won't be ambiguous.
//using std::endl; // Added so that endl won't be ambiguous.
//using std::system; // Added so that system won't be ambiguous.
// Main function
int main()
{
// ******************* variable declaration ******************
char mainLoopCode;
int statusCode;
int statusCodeConfirm;
int taxIncomeReentryCode;
int taxIncomeReentryCodeConfirm;
float taxableIncome;
float taxableIncomeConfirm;
float taxAmt;
int statusCodeInfo;
int taxIncomeReentryCodeInfo;
float fixed;
// ************************ MAIN LOOP ************************
do
{
// ******************** STATUSCODE MODULE ********************
do
{
// Prompt The User To Input Status Code
cout<<endl<< "Here are your choices:" <<endl<<endl
<< "1 = Single" <<endl
<< "2 = Married Filing Jointly" <<endl
<< "3 = Married Filing Seperately" <<endl
<< "4 = Head of House" <<endl
<< "9 = End Processing" <<endl<<endl
<< "Please enter your selection and press enter " <<endl<<endl;
cin >> statusCode;
cout<<endl;
// Use Users Input To Confirm Status Code
switch (statusCode)
{
case 1 : cout <<"You Have Selected 1 = Single."<<endl<<endl;
statusCodeInfo=1;
cout << "Please Confirm Your Selection By Entering It Again:" <<endl<<endl;
cin >> statusCodeConfirm;
if (statusCode == statusCodeConfirm)
{
cout << endl << "Confirmed Your Selection 1 = Single." <<endl<<endl;
break;
}
else
statusCode = 0;
cout << endl << "You Seem To Be Having Some Difficulty." <<endl;
cout << "Please Enter The Number That Applies To You And " <<endl;
cout << "Confirm That Number When Asked Next To Confirm It. Thank You." <<endl<<endl;
break;
case 2 : cout <<"You have Selected 2 = Married Filing Jointly."<<endl<<endl;
statusCodeInfo = 2;
cout << "Please Confirm Your Selection By Entering It Again:" <<endl<<endl;
cin >> statusCodeConfirm;
if (statusCode == statusCodeConfirm)
{
cout << endl << "Confirmed Your Selection 2 = Married Filing Jointly." <<endl<<endl;
break;
}
else
statusCode = 0;
cout << endl << "You Seem To Be Having Some Difficulty." <<endl;
cout << "Please Enter The Number That Applies To You And " <<endl;
cout << "Confirm That Number When Asked Next To Confirm It. Thank You." <<endl<<endl;
break;
case 3 : cout <<"You Have Selected 3 = Married Filing Seperately."<<endl<<endl;
statusCodeInfo = 3;
cout << "Please Confirm Your Selection By Entering It Again:" <<endl<<endl;
cin >> statusCodeConfirm;
if (statusCode == statusCodeConfirm)
{
cout << endl << "Confirmed Your Selection 3 = Married Filing Seperately." <<endl<<endl;
break;
}
else
statusCode = 0;
statusCodeInfo =0;
cout << endl << "You Seem To Be Having Some Difficulty." <<endl;
cout << "Please Enter The Number That Applies To You And " <<endl;
cout << "Confirm That Number When Asked Next To Confirm It. Thank You." <<endl<<endl;
break;
case 4 : cout <<"You Have Selected 4 = Head of House."<<endl<<endl;
statusCodeInfo = 4;
cout << "Please Confirm Your Selection By Entering It Again:" <<endl<<endl;
cin >> statusCodeConfirm;
if (statusCode == statusCodeConfirm)
{
cout << endl << "Confirmed Your Selection 4 = Head of House." <<endl<<endl;
break;
}
else
statusCode = 0;
statusCodeInfo =0;
cout << endl << "You Seem To Be Having Some Difficulty." <<endl;
cout << "Please Enter The Number That Applies To You And " <<endl;
cout << "Confirm That Number When Asked Next To Confirm It. Thank You." <<endl<<endl;
break;
case 9 : cout <<"You Have Selected 9 = End Processing"<<endl<<endl;
statusCodeInfo =0;
break;
default :
statusCode = 0;
}
}
while (statusCode < 1);
if(statusCode == 9)
return 0;
// ******************* TAXABLEINCOME MODULE ******************
// Prompt The User To Input Taxable Income
do
{
cout << "Please Enter The Dollar Amount Of Your Taxable Income:" <<endl<<endl;
cin >> taxableIncome;
cout<<endl;
if(taxableIncome >= 500)
{
cout<<"You Entered $" << taxableIncome << " For Your Taxable Income." <<endl<<endl;
cout << "Please Confirm By Reentering Your Taxable Income:" <<endl<<endl;
cin >> taxableIncomeConfirm;
cout <<endl<<endl;
if (taxableIncome == taxableIncomeConfirm)
break;
else
cout << "You Seem To Be Having Difficulty." <<endl<<endl;
}
else
{
cout << "You Have Entered An Amount That Is To Low. " <<endl;
cout << "If The Amount You Entered Is Correct" <<endl;
cout << "You Owe No Taxes. Otherwise ... "
<<endl<<endl;
do
{
// Prompt The User To Input Status Code
cout<< "Here are your choices:" <<endl<<endl
<< "1 = To Reenter Your Taxable Income" <<endl
<< "9 = End Processing" <<endl<<endl
<< "Please enter your selection and press enter " <<endl<<endl;
cin >> taxIncomeReentryCode;
cout<<endl;
// Use Users Input To Confirm Status Code
switch (taxIncomeReentryCode)
{
case 1 : cout <<"You Have Selected 1 = Single."<<endl<<endl;
taxIncomeReentryCodeInfo =1;
cout << "Please Confirm Your Selection By Entering It Again:" <<endl<<endl;
cin >> taxIncomeReentryCodeConfirm;
if (taxIncomeReentryCode == taxIncomeReentryCodeConfirm)
{
cout << endl << "Confirmed Your Selection 1 = For Reenter." <<endl<<endl;
break;
}
else
taxIncomeReentryCode = 0;
taxIncomeReentryCodeInfo =0;
cout << endl << "You Seem To Be Having Some Difficulty." <<endl;
cout << "Please Enter The Number That Applies To You And " <<endl;
cout << "Confirm That Number When Asked Next To Confirm It. Thank You." <<endl<<endl;
break;
case 9 : cout <<"You Have Selected 9 = End Processing"<<endl<<endl;
taxIncomeReentryCodeInfo =0;
break;
default :
taxIncomeReentryCode = 0;
}
}
while (taxIncomeReentryCode < 1);
if(taxIncomeReentryCode == 9)
return 0;
}
}
while (taxableIncome <= 500);
// ********************** TAXAMT MODULE **********************
do
{
// Calculate the amount of tax owed
switch (statusCode)
{
case 1 : cout <<"You Have Selected 1 = Single"<<endl<<endl;
if (taxableIncome >= 336551)
{
taxAmt = (((7550)*0.1f)+((23100)*0.15f)+((43550)*0.25f)+((80600)*0.28f)+((181750)*0.33f)+((taxableIncome-7550-23100-43550-80600-181750)*0.35f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 154801 && taxableIncome <= 336550)
{
taxAmt = (((7550)*0.1f)+((23100)*0.15f)+((43550)*0.25f)+((80600)*0.28f)+((taxableIncome-7550-23100-43550-80600)*0.33f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 74201 && taxableIncome <= 154800)
{
taxAmt = (((7550)*0.1f)+((23100)*0.15f)+((43550)*0.25f)+((taxableIncome-7550-23100-43550)*0.28f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 30651 && taxableIncome <= 74200)
{
taxAmt = (((7550)*0.1f)+((23100)*0.15f)+((taxableIncome-7550-23100)*0.25f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 7551 && taxableIncome <= 30650)
{
taxAmt = (((7550)*0.1f)+((taxableIncome-7550)*0.15f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 500 && taxableIncome <= 7550)
{
taxAmt = ((taxableIncome)*0.1f);
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else
cout << "Error In taxAmt Case 1 Calculation, Please Contact Programmer"<<endl;
case 2 : cout <<"You Have Selected 2 = Married Filing Jointly"<<endl<<endl;
if (taxableIncome >= 336551)
{
taxAmt = (((15100)*0.1f)+((46200)*0.15f)+((62400)*0.25f)+((64750)*0.28f)+((148100)*0.33f)+((taxableIncome-15100-46200-62400-64750-148100)*0.35f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 188451 && taxableIncome <= 336550)
{
taxAmt = (((15100)*0.1f)+((46200)*0.15f)+((62400)*0.25f)+((64750)*0.28f)+((taxableIncome-15100-46200-62400-64750)*0.33f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 123701 && taxableIncome <= 188450)
{
taxAmt = (((15100)*0.1f)+((46200)*0.15f)+((62400)*0.25f)+((taxableIncome-15100-46200-62400)*0.28f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 61301 && taxableIncome <= 123700)
{
taxAmt = (((15100)*0.1f)+((46200)*0.15f)+((taxableIncome-15100-46200)*0.25f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 15101 && taxableIncome <= 61300)
{
taxAmt = (((15100)*0.1f)+((taxableIncome-15100)*0.15f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 500 && taxableIncome <= 15100)
{
taxAmt = ((taxableIncome)*0.1f);
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else
cout << "Error In taxAmt Case 2 Calculation, Please Contact Programmer"<<endl;
case 3 : cout <<"You Have Selected 3 = Married Filing Seperately"<<endl<<endl;
if (taxableIncome >= 336551)
{
taxAmt = (((7550)*0.1f)+((23100)*0.15f)+((31200)*0.25f)+((32375)*0.28f)+((74050)*0.33f)+((taxableIncome-7550-23100-31200-32375-74050)*0.35f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 154801 && taxableIncome <= 336550)
{
taxAmt = (((7550)*0.1f)+((23100)*0.15f)+((31200)*0.25f)+((32375)*0.28f)+((taxableIncome-7550-23100-31200-32375)*0.33f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 74201 && taxableIncome <= 154800)
{
taxAmt = (((7550)*0.1f)+((23100)*0.15f)+((31200)*0.25f)+((taxableIncome-7550-23100-31200)*0.28f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 30651 && taxableIncome <= 74200)
{
taxAmt = (((7550)*0.1f)+((23100)*0.15f)+((taxableIncome-7550-23100)*0.25f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 7551 && taxableIncome <= 30650)
{
taxAmt = (((7550)*0.1f)+((taxableIncome-7550)*0.15f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 500 && taxableIncome <= 7550)
{
taxAmt = ((taxableIncome)*0.1f);
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else
cout << "Error In taxAmt Case 3 Calculation, Please Contact Programmer"<<endl;
case 4 : cout <<"You Have Selected 4 = Head of House"<<endl<<endl;
if (taxableIncome >= 336551)
{
taxAmt = (((10750)*0.1f)+((30300)*0.15f)+((64950)*0.25f)+((65650)*0.28f)+((164900)*0.33f)+((taxableIncome-10750-30300-64950-65650-164900)*0.35f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 154801 && taxableIncome <= 336550)
{
taxAmt = (((10750)*0.1f)+((30300)*0.15f)+((64950)*0.25f)+((65650)*0.28f)+((taxableIncome-10750-30300-64950-65650)*0.33f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 74201 && taxableIncome <= 154800)
{
taxAmt = (((10750)*0.1f)+((30300)*0.15f)+((64950)*0.25f)+((taxableIncome-10750-30300-64950)*0.28f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 30651 && taxableIncome <= 74200)
{
taxAmt = (((10750)*0.1f)+((30300)*0.15f)+((taxableIncome-10750-30300)*0.25f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 7551 && taxableIncome <= 30650)
{
taxAmt = (((10750)*0.1f)+((taxableIncome-10750)*0.15f));
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else if(taxableIncome >= 500 && taxableIncome <= 7550)
{
taxAmt = ((taxableIncome)*0.1f);
cout << "The Tax Owed Is " << taxAmt <<endl<<endl;
break;
}
else
cout << "Error In taxAmt Case 4 Calculation, Please Contact Programmer"<<endl;
default : cout <<"Error In taxAmt, Please Contact The Programmer."<<endl<<endl;
}
}
while (statusCode < 1);
cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout<< "***********************************************"<<endl;
cout<< "* Tax Breakdown *" <<endl;
cout<< "***********************************************"<<endl;
cout<< "* Status Code: " << statusCode <<endl;
cout<< "* Filing Status: " << statusCodeInfo <<endl;
cout<< fixed << setprecision(2) << "* Taxable Income: $" << taxableIncome <<endl;
cout<< fixed << setprecision(2) << "* Tax Amount Owed: $" << taxAmt<<endl;
cout<< "***********************************************"<<endl<<endl<<endl<<endl<<endl;
mainLoopCode = 'c';
//system("pause"); // pauses system
}
while (mainLoopCode == 'c');
return 0;
}