Difference between revisions of "CSC111 Homework 1 Solution"
(→Source Code) |
|||
Line 3: | Line 3: | ||
<source lang="python"> | <source lang="python"> | ||
# hw1.py | # hw1.py | ||
− | # Kristina Fedorenko | + | # Kristina Fedorenko |
# 111c-aq | # 111c-aq | ||
# | # | ||
Line 54: | Line 54: | ||
</source> | </source> | ||
+ | |||
==Output== | ==Output== | ||
Revision as of 17:20, 9 February 2010
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!