Question

In: Computer Science

[Python programming] Functions, lists, dictionary, classes CANNOT BE USED!!! This assignment will give you more experience...

[Python programming]

Functions, lists, dictionary, classes CANNOT BE USED!!!

This assignment will give you more experience on the use of:

1. integers (int)

2. floats (float)

3. conditionals(if statements)

4. iteration(loops)

The goal of this project is to make a fictitious comparison of the federal income. You will ask the user to input their taxable income. Use the income brackets given below to calculate the new and old income tax. For the sake of simplicity of the project we will only consider individuals and not married users. We will also ignore any tax deductions while calculating income tax—they can significantly alter the tax, but add too much complexity for our programming project.

New income tax brackets (2018 and newer)

10% Up to $9,525

12% $9,526 to $38,700

22% $38,701 to $82,500

24% $82,501 to $157,500

32% $157,501 to $200,000

35% $200,001 to $500,000

37% over $500,000

Old income tax brackets (2017 and older)

10% Up to $9,325

15% $9,326 to $37,950

25% $37,951 to $91,900

28% $91,901 to $191,650

33% $191,651 to $416,700

35% $416,701 to $418,400

39.6% over $418,400

Project Description

Your program must meet the following specifications:

1. At program start, prompt the user for their income

2. Repeatedly prompt the user for new income until a negative income is entered.

3. Calculate the income tax using the 2017 and 2018 tax bracket tables above.

4. For each income entered:

a. Calculate the 2017 income tax and store it in a variable.

b. Next calculate the 2018 income tax and store it in a variable

c. Print

i. The income

ii. The 2017 taxi

iii. The 2018 tax

iv. The difference between the 2018 and 2017 tax rounded to cents

v. The difference between the 2018 and 2017 tax as a percentage of the 2017 tax rounded to cents

Assignment Notes

1. To clarify the project specifications, sample output is appended to the end of this document.

2. Use a while loop with a Boolean that keeps looping as long as the income is greater than or equal to zero.

3. Prompt for income before the loop and remember to convert the input string to an int (so you are comparing an int in your Boolean expression). Remember to prompt again at the end (aka “bottom”) of the loop.

4. There will be no error checking in this assignment. If a float or a string is entered at the prompt, the program will crash.

Solutions

Expert Solution

N=1 #assigned The value of N to 1 for first time executable in while loop
while N>0:
    N=int(input("Enter your income: "))
    if N<1:
        break
    N1=N #Store the value of N into N1 & N2 for reuse
    N2=N

    #New income tax brackets (2018 and newer)
    if N1<=9525:
        N1=N1*0.1
    elif N1>=9526 and N1<=38700:
        N1=N1*0.12
    elif N1>=38701 and N1<=82500:
        N1=N1*0.22
    elif N1>=82501 and N1<=157500:
        N1=N1*0.24
    elif N1>=157501 and N1<=200000:
        N1=N1*0.32
    elif N1>=200001 and N1<=500000:
        N1=N1*0.35
    else :
        N1=N1*0.37
    #Old income tax brackets (2017 and older)
    if N2<=9325:
        N2=N2*0.1
    elif N2>=9326 and N2<=37950:
        N2=N2*0.15
    elif N2>=37951 and N2<=91900:
        N2=N2*0.25
    elif N2>=91901 and N2<=191650:
        N2=N2*0.28
    elif N2>=191651 and N2<=416700:
        N2=N2*0.33
    elif N2>=416701 and N2<=418400:
        N2=N2*0.35
    else :
        N2=N2*0.396
    D=N2-N1
    P=D*100/N2
    print("Income: {}$".format(N))
    print("The 2018 TAX for entered income is {:.2f}$".format(N1))
    print("The 2017 TAX for entered income is {:.2f}$".format(N2))
    print("The difference between the 2018 and 2017: {:.2f}$".format(D))
    print("The difference between the 2018 and 2017 tax as a percentage of the 2017: {:.2f}%".format(P)) # we used format method for decimal and formatting

Note: we used "#" for comment in Python


Related Solutions

Programming Activity 7 - Guidance ================================= This assignment uses a built-in Python dictionary. It does not...
Programming Activity 7 - Guidance ================================= This assignment uses a built-in Python dictionary. It does not use a dictionary implementation from the textbook collections framework. It does not require any imports/files from the textbook collections framework. This week's "examplePythonDictionary.py" example uses a built-in Python dictionary. Note that the mode() function begins by creating an empty Python dictionary. You must use this dictionary in the following parts. Part 1 ------ In this part you will add entries to the dictionary. Use...
PYTHON...... Working with lists, functions, and files Objective: Work with lists Work with lists in functions...
PYTHON...... Working with lists, functions, and files Objective: Work with lists Work with lists in functions Work with files Assignment: Part 1: Write a program to create a text file which contains a sequence of test scores. Ask for scores until the user enters an empty value. This will require you to have the scores until the user enters -1. After the scores have been entered, ask the user to enter a file name. If the user doesn’t not enter...
Python Programming This assignment will give you practice with interactive programs, if/else statements, collections, loops and...
Python Programming This assignment will give you practice with interactive programs, if/else statements, collections, loops and functions. Problem Description A small car yard dealing in second hand cars needs an application to keep records of cars in stock. Details of each car shall include registration(rego), model, color, price paid for the car (i.e. purchase price) and selling price. Selling price is calculated as purchased price plus mark-up of 30%. For example, Toyota Corolla bought for $20,000 will have the selling...
This assignment will give you more experience on the use of: 1. integers (int) 2. floats...
This assignment will give you more experience on the use of: 1. integers (int) 2. floats (float) 3. conditionals 4. iteration The goal of this project is to make a fictitious comparison of the federal income. You will ask the user to input their taxable income. Use the income brackets given below to calculate the new and old income tax. For the sake of simplicity of the project we will only consider individuals and not married users. We will also...
This assignment will give you more experience on the use of: 1. integers (int) 2. floats...
This assignment will give you more experience on the use of: 1. integers (int) 2. floats (float) 3. conditionals(if statements) 4. iteration(loops) Functions, lists, dictionary, classes CANNOT BE USED!!! The goal of this project is to make a fictitious comparison of the federal income. You will ask the user to input their taxable income. Use the income brackets given below to calculate the new and old income tax. For the sake of simplicity of the project we will only consider...
PYTHON Computer Science Objectives Work with lists Work with functions Work with files Assignment Write each...
PYTHON Computer Science Objectives Work with lists Work with functions Work with files Assignment Write each of the following functions. The function header must be implemented exactly as specified. Write a main function that tests each of your functions. Specifics In the main function ask for a filename and fill a list with the values from the file. Each file should have one numeric value per line. This has been done numerous times in class. You can create the data...
Use Python for this quetions: Write a python functions that use Dictionary to: 1) function name...
Use Python for this quetions: Write a python functions that use Dictionary to: 1) function name it addToDictionary(s,r) that take a string and add it to a dictionary if the string exist increment its frequenc 2) function named freq(s,r) that take a string and a record if the string not exist in the dictinary it return 0 if it exist it should return its frequancy.
Starting out with python Lists and Tuples - US Population Data In this assignment, you will...
Starting out with python Lists and Tuples - US Population Data In this assignment, you will be reading the contents of a file into a list. This file contains the midyear population of the United States, in thousands, during the years 1950 through 1990. The first line in the file contains the population for 1950, the second line contains the populations for 1951, and so forth. You will ask the user to input a specific year to check the population...
Explain event-driven programming in Python. Give 2 examples of code where event-driven programming is used.
Explain event-driven programming in Python. Give 2 examples of code where event-driven programming is used.
python 3.6: You will have two functions: Function 1: update(user_dictionary): This function will take a dictionary...
python 3.6: You will have two functions: Function 1: update(user_dictionary): This function will take a dictionary entry as user that has keys, ‘username’,’password’,’uid’, and ‘gid’ along with values. You will search if the username is already in your user_list that you get from your userfile.json file that you have created in your previous task. If the username in your user_dictionary is not in the list that is in your .json file then add the user_dictionary into the existing list and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT