Skip to content
Sign upLog in
← Back to Community

Python Financial assistance: somebody can help me to fix my code script and fix errors. thanks

Profile icon
tainguyen3

Financial Assistance:
A non-governmental organization needs a program to calculate the amount of financial assistance for needy families.
The formula is as follows:
• If the annual household income is between $30,000 and $40,000 and the household has at least three children, the amount is $1,000 per child.
• If the annual household income is between $20,000 and $30,000 and the household has at least two children, the amount is $1,500 per child.
• If the annual household income is less than $20,000, the amount is $2,000 per child. Write a program that asks for the house-hold income and number of children for each applicant, printing the amount returned by your function.
Input function Specs 1. def get_income() This function requests an annual household income from the user and continues to ask for the income value unntil the user gets it right. This function should not accept any arguments.

  1. def get_number() This function requests a number of children and continues to ask for the number until the user gets it right. This function should not accept any arguments.
  2. def compute_assistance(income, number) This function accepts both the annual household income and the number of children as parameters and return the amount of financial assistance.

def computeAssistance(income, children):
returnString = ""
#check the range that income falls in

if income in range(30000, 40000):
assistance = 1000
returnString += "Assistance: $"+ str(assistance)+"/child \n"
returnString += "Total assistance: $" + str(assistance * children)
elif income in range(20000, 30000):
assistance = 1500
returnString += "Assistance: $"+str(assistance)+"/child\n"
returnString += "Total assistance: $" + str(assistance * children)
elif income in range(0, 20000):
assistance = 2000
returnString += "Assistance: $"+ str (assistance)+"/child\n"
returnString += "Total assistance: $"+ str (assistance*children)
else:
returnString += "No assistance"
return returnString

#display welcome message

print("Welcome to household financial assistance calculator.")
print("Enter -1 to exit.")
try:
while True:

#prompt user for income and no. of

childrenincome = int(input("Please enter household income amount: \n"))
if income == -1:
exit()
children = int(input("Please enter
number of children in the household: \n"))
if children == -1:
exit()
#call the computeAssistance() function
assistance = computeAssistance (income, children)
#display result
print(assistance+"\n")
except ValueError:
print("Please enter integer input!")

Voters
Profile icon
tainguyen3
Comments
hotnewtop
Profile icon
TannerTommy

I want to help you with your script but it's just way too complicated. I want to get details assignment so I can put more time in this script. Can someone help me here?

Profile icon
ash15khng

What errors are there? Also can you link to a repl?

Profile icon
tainguyen3

@ash15khng
how can i link it to repl

Profile icon
ash15khng

@tainguyen3
Paste your repl link here.