In: Computer Science
In PYTHON
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. Implement a function for this computation. Write a program that asks for the household income and number of children for each applicant, printing the amount returned by your function. Use –1 as a sentinel value for the input.
If you need any corrections/clarifications kindly comment.
Program
income=None
sum=0
print("Financial Assistance Calculator\n")
income=(float(input("Please enter your house hold income:
")))
while income!=-1:
sum=0
num_child=(int(input("Please enter your total
number of children: ")))
if income<20000:
sum=num_child*2000
elif income<30000 and income>20000:
if
num_child>=2:
sum=num_child*1500
elif income<40000 and income>30000:
if
num_child>=3:
sum=num_child*1000
print("You qualify for : ${:0.2f}".format(sum),"
in aid.")
income=(float(input("\nPlease enter your house
hold income: ")))
print("Thank you for using Financial Assistance Calculator!")
Output
Financial Assistance Calculator
Please enter your house hold income: 30500
Please enter your total number of children: 4
You qualify for : $4000.00 in aid.
Please enter your house hold income: 15000
Please enter your total number of children: 3
You qualify for : $6000.00 in aid.
Please enter your house hold income: -1
Thank you for using Financial Assistance Calculator!
Screenshot