In: Computer Science
def stateTax(amount):
taxRate = 0.05
taxAmount = taxRate * amount
print('State tax: ',taxAmount)
return taxAmount
def countyTax(amount):
taxRate = 0.025
taxAmount = taxRate * amount
print('County tax: ',taxAmount)
return taxAmount
def totalTax(state,county):
taxAmount = state + county
print('Total tax: ',taxAmount)
return taxAmount
def totalAmount(amount, tax):
total = amount + tax
return total
def main():
amount = float(input('Enter the amount of purchase: '))
sTax = stateTax(amount)
cTax = countyTax(amount)
tTax = totalTax(sTax,cTax)
print('Total amount including tax is: ' ,total)
main()
I am a student using python programing.
My goal is to
1. Enter purchase amount
2. Compute State tax
3. Compute County tax
4. Display purchase amount
5. Display state tax
6. Display county tax
7. Display total sales tax
8. Display Total of Sale
How can I fix my line 26 to define total from error saying total is not defined?
Correct code:
# Calculates stateTax and returns stateTax amount
def stateTax(amount):
taxRate = 0.05
taxAmount = taxRate * amount
print('State tax: ',taxAmount)
return taxAmount
# Calculates countyTax and returns countyTax
amount
def countyTax(amount):
taxRate = 0.025
taxAmount = taxRate * amount
print('County tax: ',taxAmount)
return taxAmount
# Calculates sum of stateTax and countyTax returns Total
Tax amount
def totalTax(state,county):
taxAmount = state + county
print('Total tax: ',taxAmount)
return taxAmount
# Calculates sum of purchase and tax and returns total
sale
def totalAmount(amount, tax):
total = amount + tax
return total
def main():
amount = float(input('Enter the amount of purchase: '))
sTax = stateTax(amount) ## State Tax is stored in sTax
cTax = countyTax(amount) ## Country Tax is stored in cTax
tTax = totalTax(sTax,cTax) ## Total Tax is stored in sTax
# calling totalAmount function by passing purchase amount and total
tax
tSale = totalAmount(amount,tTax)## Total sale is amount is stored
in tSale
print('Total amount including tax is: ' ,tSale)
main()
OUTPUT:
ERRORS YOU MADE: