CITP4350 Assignment 2 Create a class named “Taxpayer”. · Data fields for Taxpayer class include the Social Security number (use a string for the type, but do not use dashes within the number), the...

1 answer below »
Hello!! Attached is the assignment I need help with this week. Thanks all!


CITP4350 Assignment 2 Create a class named “Taxpayer”. · Data fields for Taxpayer class include the Social Security number (use a string for the type, but do not use dashes within the number), the yearly gross income, the tax owed, and totalTaxAmt (static variable). · The class includes the properties with get and set for the first two data fields, but make the tax owed a read-only property. The tax should be calculated whenever the income is set. Assume the tax is 15% of income for incomes under $30,000 and 28% for incomes that are $30,000 or higher. After the tax owed is calculated, the tax owed is added into totalTaxAmt. Write a main function that prompts user to enter the number of Taxpayer and creates a dynamic array of the Taxpayer objects. Prompt the user for data for each object and display total tax amount. After the main function, write a function that compare each object based on tax owed; then display the objects in order by the amount of tax owed. Save the program as TaxPayerDemo.cs.
Answered Same DaySep 20, 2021

Answer To: CITP4350 Assignment 2 Create a class named “Taxpayer”. · Data fields for Taxpayer class include the...

Sayed Shad Ahmad answered on Sep 20 2021
147 Votes
Solution/Sample_Output.png
Solution/Taxpayer.cs
using System;
//Taxpayer namespace
namespace Taxpayer
{
//Class Taxpayer
class Taxpayer
{
/*
* Instance variables of Taxpayer class to store
* social security number, yearly gross income,
* tax owed by the taxpayer & the total tax amount
*/
private String ssn;
private double gross_income;
private double tax_owed;
private static double totalTaxAmt;
//Method to get social security number of the taxpayer
public String getSsn()
{
return ssn;
}
//Method to set social security number of the taxpayer
public void setSsn(String ssn)
{
this.ssn = ssn;
}
//Method to get yearly gross income of the taxpayer
public double getGrossIncome()
{
return gross_income;
}
//Method to set yearly gross income of the taxpayer
public void setGrossIncome(double gross_income)
{
this.gross_income = gross_income;
this.calcTaxOwed();
}
//Method to calculate tax owed by the taxpayer
public void calcTaxOwed()
{
//Checking whether the yearly gross income of the taxpayer is less than $30000
if (gross_income < 30000)
//Calculating tax owed as 15% of yearly gross income of the taxpayer
tax_owed = (15 / 100.0) * gross_income;
else
//Calculating tax owed as 28% of yearly gross income of the taxpayer
tax_owed = (28 / 100.0) * gross_income;
//Adding tax owed to the toal tax amount
totalTaxAmt =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here