CSC111 Homework 1 Solution
Revision as of 18:27, 11 February 2010 by Thiebaut (talk | contribs) (moved CSC111 Homwork 1 Solution to CSC111 Homework 1 Solution)
Contents
Source Code
# hw1.py
# Kristina Fedorenko
# 111c-aq
#
# This program computes taxes for 2009
# based on user's salary and deductions. This information is
# entered by the user.
#
# To calculate the federal taxes the program
# uses the following formula: (salary - deductions) x 28%
#
# The state taxes are computed using this formula:
# (salary - deductions - 1000) x 5%
#
#
def main ():
# *^*^*^*^*^ask user to provide all the information needed*^*^*^*^*^
print
print 'Welcome!'
print
print 'This program will compute your taxes for 2009.'
print
print 'You will be asked to enter some information. Please do NOT include'
print '$ symbols or commas in your answers.'
print
first = raw_input('Please enter your first name: ')
last = raw_input('Please enter your last name: ')
salary = input('Please enter your salary for 2009: ')
deductions = input('Please enter your deductions: ')
# *^*^*^*^*^calculate federal and state taxes*^*^*^*^*^
federal = (salary - deductions)*0.28
state = (salary - deductions -1000 )*0.05
total = state + federal
# *^*^*^*^*^show results to user*^*^*^*^*^
print
print 'Dear', first, last+':'
print
print 'Your federal taxes for 2009 are:','$', federal
print
print 'Your state taxes for 2009 are: ','$', state
print
print 'You will have to pay a total of', '$', total, 'in taxes.'
print
print 'Thanks for using this program!'
print
main ()
Output
Welcome!
This program will compute your taxes for 2009.
You will be asked to enter some information. Please do NOT include
$ symbols or commas in your answers.
Please enter your first name: Sophia
Please enter your last name: Smith
Please enter your salary for 2009: 100000
Please enter your deductions: 1000
Dear Sophia Smith:
Your federal taxes for 2009 are: $ 27720.0
Your state taxes for 2009 are: $ 4900.0
You will have to pay a total of $ 32620.0 in taxes.
Thanks for using this program!