Question

In python create a TaxReturn class with attributes that hold a taxpayer's Social Security number, last...

In python create a TaxReturn class with attributes that hold a taxpayer's Social Security number, last name, first name, street address, city, state, zip code, annual income, marital status, and tax liability. Include a constructor that requires arguments that provide values for all the fields other than the tax liability. The constructor calculates the tax liability based on annual income and the percentages in the following table:

Income($) Single Married

0 - 20,000 15% 14%

20,001 - 50,000 22% 20%

50,001 and above 30% 28%

In the TaxReturn class, override the __str__ method to display the object when we call print function. In the main program, write a display function to display every taxpayer's information. Every new taxpayer should be stored in a list.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Thanks for the question.

Below is the code you will be needing  Let me know if you have any doubts or if you need anything to change.

Thank You !

Note: Please add more taxpayer objects in the TaxPayer list, for demonstration i added only 2
===========================================================================

class TaxReturn():

    def __init__(self,ssn,lname,fname,street,address,city,state,zip,income,marital):
        self.ssn=ssn
        self.lastname=lname
        self.firstname=fname
        self.street=street
        self.address=address
        self.city=city
        self.state=state
        self.zip=zip
        self.income=income
        self.marital=marital
        self.taxliability=self.calculateTaxLiability()

    def calculateTaxLiability(self):
        if self.marital=='Married' and self.income<=20000:return self.income*0.14
        if self.marital=='Married' and self.income<=50000:return self.income*0.20
        if self.marital=='Married' :return self.income*0.28

        if self.marital=='Single' and self.income<=20000:return self.income*0.15
        if self.marital=='Single' and self.income<=50000:return self.income*0.22
        if self.marital=='Single' :return self.income*0.30

    def __str__(self):
        desc='Name: {} {}, SSN: {}, Marital Status: {}'.format(self.firstname,self.lastname,self.ssn,self.marital)
        desc+='\nAddress: {},{},{} Zip: {}'.format(self.address,self.city,self.state,self.zip)
        desc+='\nIncome: ${:,.2f} Tax Liability: ${:,.2f}'.format(self.income,self.taxliability)

        return desc

def main():

    taxpayers=[]
    taxpayers.append(TaxReturn('123-45-1234','Doe','John','123','Main St','Dallas','Ohio',12345,68000,'Married'))
    taxpayers.append(TaxReturn('234-55-1334','Smith','John','67','Orange St','Westchester','Connecticut',14345,58000,'Single'))

    for taxpayer in taxpayers:
        print(taxpayer)
main()

=====================================================================

Add a comment
Know the answer?
Add Answer to:
In python create a TaxReturn class with attributes that hold a taxpayer's Social Security number, last...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Part (A) Note: This class must be created in a separate cpp file Create a class...

    Part (A) Note: This class must be created in a separate cpp file Create a class Employee with the following attributes and operations: Attributes (Data members): i. An array to store the employee name. The length of this array is 256 bytes. ii. An array to store the company name. The length of this array is 256 bytes. iii. An array to store the department name. The length of this array is 256 bytes. iv. An unsigned integer to store...

  • ASAP Please. Python Program Description Create an object-oriented program that allows you to enter data for...

    ASAP Please. Python Program Description Create an object-oriented program that allows you to enter data for employees. Specifications Create an abstract Employee class that provides private attributes for the first name, last name, email address, and social security number. This class should provide functions that set and return the employee’s first name, last name, email address, and social security number. This class has a function: get_net_income which returns 0. Create a Manager class that inherits the Employee class. This class...

  • python code? 1. Create a class called Person that has 4 attributes, the name, the age,...

    python code? 1. Create a class called Person that has 4 attributes, the name, the age, the weight and the height [5 points] 2. Write 3 methods for this class with the following specifications. a. A constructor for the class which initializes the attributes [2.5 points] b. Displays information about the Person (attributes) [2.5 points] c. Takes a parameter Xage and returns true if the age of the person is older than Xage, false otherwise [5 points] 3. Create another...

  • 4. Define a class named TaxReturn that contains a tax ID number, last name, first name,...

    4. Define a class named TaxReturn that contains a tax ID number, last name, first name, annual income, number of dependents, and amount of tax owed for a taxpayer Include constant static fields that hold the tax rates for the situations shown in the following table Income (S) 0-10,000 0,001-30,000 0,001-60,000 60,001 and up 0 dependents 0.10 0.12 0.18 0.25 1 dependent 0.08 0.11 0.15 0.22 2 or more dependents 0.07 0.09 0.13 0.19 Include a static function that displays...

  • A) Please implement a Python script to define a student class with the following attributes (instance...

    A) Please implement a Python script to define a student class with the following attributes (instance attributes): cwid: student’s CWID first_name : student’s first name last_name: student’s last name gender: student’s gender gpa: student’s gpa Please make these attributes as private ones so they have to be accessed via getter/setter methods or property. For this purpose, please define a getter/setter method and property for each of the attributes. Another thing you need to do is to define a constructor that...

  • Using Python: Par 1. You will define Student class with the following attributes: CWID: the student’s...

    Using Python: Par 1. You will define Student class with the following attributes: CWID: the student’s CWID FirstName: the student’s first name LastName: the student’s last name Gender: the student’s gender (‘M’ or ‘F’) BirthDate: the student’s date of birth (e.g. ‘03/14/1999’) ClassID: the class id that the student took ClassDate: the date when the student took the class (e.g. ‘01/26/2018’) Grade: the student’s grade for the class In addition, you will do the following tasks: Implement a set of...

  • PYTHON*************** Create a Person Class that: Accepts First Name, Last Name, Age, and Gender Has a...

    PYTHON*************** Create a Person Class that: Accepts First Name, Last Name, Age, and Gender Has a method that adds all persons Validate all input, not left empty for First Name, Last Name, Gender and numeric for age and throw an exception if it does not validate within the class. Create a Student Class that: Inherits the Person Class Accepts GPA Validate GPA (>= 0 and <= 4.0) and throw exception if it does not validate within the class. Has methods...

  • Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The...

    Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...

  • PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything...

    PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything a course uses in a grading scheme, # like a test or an assignment. It has a score, which is assessed by # an instructor, and a maximum value, set by the instructor, and a weight, # which defines how much the item counts towards a final grade. def __init__(self, weight, scored=None, out_of=None): """ Purpose: Initialize the GradeItem object. Preconditions: :param weight: the weight...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT