Question

In: Computer Science

Write a program that can be used to calculate the federal tax. The tax is calculated...

Write a program that can be used to calculate the federal tax. The tax is calculated as follows: For single people, the standard exemption is $4,000; for married people, the standard exemption is $7,000. A person can also put up to 6% of his or her gross income in a pension plan. The tax rates are as follows: If the taxable income is:

  • Between $0 and $15,000, the tax rate is 15%.
  • Between $15,001 and $40,000, the tax is $2,250 plus 25% of the taxable income over $15,000.
  • Over $40,000, the tax is $8,460 plus 35% of the taxable income over $40,000. Prompt the user to enter the following information:
  • Marital status
  • If the marital status is “married,” ask for the number of children under the age of 14
  • Gross salary (If the marital status is “married” and both spouses have income, enter the combined salary.)
  • Percentage of gross income contributed to a pension fund Your program must consist of at least the following functions:
    • Function getData: This function asks the user to enter the relevant data.
    • Function taxAmount: This function computes and returns the tax owed.

To calculate the taxable income, subtract the sum of the standard exemption, the amount contributed to a pension plan, and the personal exemption, which is $1,500 per person. (Note that if a married couple has two children under the age of 14, then the personal exemption is $1,500 ∗ 4 = $6,000.)

Since your program handles currency, make sure to use a data type that can store decimals with a decimal precision of 2.

Solutions

Expert Solution

Program:

#include <iostream>

using namespace std;

void getData(char *m,int *s, float *g, float *p, int *c, float *t)
{
cout<<"Are you married?(Y/N): ";
cin>>*m;
if(*m=='Y')
{
*s=7000;
cout<<"Enter number of children you have below 14 years of age: ";
cin>>*c;
cout<<"Enter combined salary of both the spouses, if both have income. Else enter only your income: ";
cin>>*g;
cout<<"Enter percentage(must be less than 6%) of gross income contributed to a pension fund: ";
cin>>*p;
if((*p)<0||(*p)>6)
{
while((*p)>=0&&(*p)<=6)
{
cout<<"Percentage must be between 0 and 6, both inclusive.: ";
cin>>*p;
}
}
*t=*g-(*s+((*p)*(*g))/100+(2+(*c))*1500);
}
else
{
*s=4000;
cout<<"Enter gross salary: ";
cin>>*g;
cout<<"Enter percentage(must be less than 6%) of gross income contributed to a pension fund: ";
cin>>*p;
if((*p)<0||(*p)>6)
{
while((*p)>=0&&(*p)<=6)
{
cout<<"Percentage must be between 0 and 6, both inclusive.: ";
cin>>*p;
}
}
*t=*g-(*s+(((*p)*(*g))/100)+1500);
}
}

float taxAmount(float t)
{
if(t<=15000)
return (0.15*t);
else if(t>15000&&t<=40000)
return (2250+(0.25*(t-15000)));
else
return (8460+(0.35*(t-40000)));
}

int main()
{
char maritalStatus;
float grossSalary,pensionPlanContribution,taxableIncome,tax;
int childrens=0,standardExemption;;
getData(&maritalStatus,&standardExemption,&grossSalary,&pensionPlanContribution,&childrens,&taxableIncome);
tax=taxAmount(taxableIncome);
cout<<"\nTax owed = "<<tax;
return 0;
}

Screenshot of the Code:

Output 1:

Output 2:


Related Solutions

C++ Write a program that can be used to calculate the federal tax. The tax is...
C++ Write a program that can be used to calculate the federal tax. The tax is calculated as follows: for single people, the standard exemption is $4,000; for married people, the standard exemption is $7,000. A person can also put up to 6% of his or her gross income in a pension plan. the tax rates are as follows: if the taxable income is: Between $0 and $15,000, the tax rate is 15%. Between $15,001 and 40,000 the tax rate...
Write a program that can calculate the amount of federal tax aperson owes for the...
Write a program that can calculate the amount of federal tax a person owes for the upcoming year.After calculating the amount of tax owed, you should report to the user their filing status (single/joint), which tax rate they fell under, as well as the tax owed. Example: “As a single filer you fell under 12% tax bracket and you owe $3500.”Disclaimer: This example is simplified and is not intended to be an accurate representation of how to calculate your taxes.Your...
Write a program that can be used to calculate the commission earned in a real estate...
Write a program that can be used to calculate the commission earned in a real estate transaction. The chart below describes the formulas used to calculate the commission. Your program will ask the user for the sales price as an double, calculate the commission, and display the sales price and commission. Remember to use constants rather than “magic numbers”. Sales Price Commission Less than $100,000 5% of the sales price $100,000 to $300,000 $5,000 + 10% of the amount of...
Write a program that will calculate a 15% tip and a 13% tax on a meal...
Write a program that will calculate a 15% tip and a 13% tax on a meal price. The user will enter the meal price and the program will calculate tip, tax, and the total. The total is the meal price plus the tip plus the tax. Your program will then display the values of tip, tax, and total. Please format the output, also the round up to 2 decimal places. Write the code in python.
1) Write a program in C++ sin(x) can be approximately calculated using the following formula, where...
1) Write a program in C++ sin(x) can be approximately calculated using the following formula, where n! is factorial(n) – for example 3!=3*2*1 = 6 (the function in previous problem). The more terms we use in the series, the higher will be accuracy of the calculations. By using infinite terms in the series we will have the exact value. Hint 1: For n! simply use (copy and paste) the factorialFunc(n)from previous problem. Hint 2: This problems is similar to the...
in c++ Write a program that can calculate the arithmetic mean, the geometric mean, and the...
in c++ Write a program that can calculate the arithmetic mean, the geometric mean, and the harmonic mean of a set of five numbers. •The program should ask the user to enter fiver numbers, calculate the means, and print all the data to a text file. The program should output the expected results.•Example: The text file should read: For the set of numbers {1,2,3}. The arithmetic mean is 2, the geometric mean is about 1.82, and the harmonic mean is...
Wage and Tax Statement Data on Employer Federal Insurance Contributions Act tax used to finance federal...
Wage and Tax Statement Data on Employer Federal Insurance Contributions Act tax used to finance federal programs for old-age and disability benefits (social security) and health insurance for the aged (Medicare).FICA Tax Ehrlich Co. began business on January 2, 20Y8. Salaries were paid to employees on the last day of each month, and social security tax, Medicare tax, and federal income tax were withheld in the required amounts. An employee who is hired in the middle of the month receives...
Write a program in JAVA using the BigInteger library that can be used to check a...
Write a program in JAVA using the BigInteger library that can be used to check a RSA signature, based on the signer's RSA public key pair. To test your program, take the following information about a message Alice signed and use the verify signature to reproduce the message Alice signed and convert it back to String format. n = 68236588817658935156357212288430888402056854883696767622850112840388111129987 e = 65537 signature = 46612763171375975923246342580942010388414761162366281695045830390867474569531
The United States federal personal income tax is calculated based on filing status and taxable income....
The United States federal personal income tax is calculated based on filing status and taxable income. There are four filing statuses (in this program we’ll use only three): single filers, married filing jointly, and head of household. The tax rates vary every year. Table 1 shows the rates for 2016. If you are, say, single with a taxable income of $10,000, the first $9,075 is taxed at 10% and the other $925 is taxed at 15%. So, your tax is...
1) Write a functional program in Java that can calculate the volume and surface area of...
1) Write a functional program in Java that can calculate the volume and surface area of a sphere and a cube 2) Write a procedural program in Java that can calculate the volume and surface area of a sphere and a cube 3) Write an Object Oriented Program in Java that can find the volume and surface area of a sphere and cube
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT