Question

In: Computer Science

Write a function that implements the following formula to calculates the amount of financial assistance for...

Write a function that implements the following formula to calculates the amount of financial assistance for families in need:
• If the annual family income is between $30,000 and $40,000 and the family has at least 3 children, the assistance amount will be $1,000 per child.
• If the annual family income is between $20,000 and $30,000 and the family has at least 2 children, the assistance amount will be $1,500 per child.
• If the annual family income is less than $20,000, the assistance amount will be $1,000 per child.
Write a program that asks for the family income and their number of children, then prints the amount of assistance that your function returns. Use -10, as a sentinel value for the input.

Solutions

Expert Solution

The solution is coded in Python 3.9 programmin language.

The code snippet of the required program is attached below:

def financial_assistance(inc,child):
    if(inc>30000 and inc <= 40000 and child>=3):
        print("The financial assistance amount is: $",str(1000*child))
    
    elif(inc>=20000 and inc <= 30000 and child>=2):
        print("The financial assistance amount is: $",str(1500*child))

    elif(inc < 20000):
        print("The financial assistance amount is: $",str(1000*child))

    else:
        print("No financial assistance available")




sentinel = 1
while(sentinel != -10):
    fam_income = int(input("Enter the annual family income: $"))
    children = int(input("Enter the number of children in the family:"))
    financial_assistance(fam_income,children)
    print("Do you want to calculate financial assistance for another family?")
    print("Enter -10 to quit and 1 to continue")
    sentinel = int(input())
                         

we have created a function financial_assistance to calculate the financial assistance based on the values of family income and number of children which is provided as arguments from the main program.

The if ..elif..else ladder is coded in according to the conditions provided in the question.

In the main loop the user is requested to provide values of family income and number of children and after calculating the financial assistance the user is asked whether he wants to continue or not.

If the input provided by user is -10 then the program ends running.

The screenshot of the program and the output generated is attached for your reference;

Hope this helps!!!


Related Solutions

Python 3: Write a function called Interest with floating point parameters Amount and InterestPercent that calculates...
Python 3: Write a function called Interest with floating point parameters Amount and InterestPercent that calculates the simple interest on Amount using InterestPercent as the interest rate.The function should return the interest amount.
Write a Java program (use JDBC to connect to the database) that implements the following function...
Write a Java program (use JDBC to connect to the database) that implements the following function (written in pseudo code): (20 points) CALL RECURSION ( GIVENP# ) ; RECURSION: PROC ( UPPER_P# ) RECURSIVE ; DCL UPPER_P# ... ; DCL LOWER_P# ... INITIAL ( ' ' ) ; EXEC SQL DECLARE C CURSOR FOR SELECT MINOR_P# FROM PART_STRUCTURE WHERE MAJOR_P# = :UPPER_P# AND MINOR_P# > :LOWER_P# ORDER BY MINOR_P# ; print UPPER_P# ; DO "forever" ; EXEC SQL OPEN C...
Using Python write a function that implements the following two-dimensional objective function: F (x, y) =...
Using Python write a function that implements the following two-dimensional objective function: F (x, y) = (x^2 + y − 11)^2 + (x + y^2 − 7 )^22 . Determine how many local minimums and maximums and their location for this objective function.
Description: The purpose of this assignment is to write code that calculates the amount of interest...
Description: The purpose of this assignment is to write code that calculates the amount of interest accrued on a credit card on its expenses. You will create a C program that prompts the user for the total amount of purchases on the credit card, an annual percentage rate (APR), and the number of days the money is borrowed. The program will calculate the amount of the compound interest for the purchases, then print the original amount of purchases, the amount...
Read the function definitions of the two functions: “compute_st_ave” and “compute_quiz_ave”. Write a function that calculates...
Read the function definitions of the two functions: “compute_st_ave” and “compute_quiz_ave”. Write a function that calculates the average of student averages. (Student averages are stored in st_ave [5] array). Include a statement to print this average on the screen. Declare this function above the “main” function where other functions are declared. In the main program, invoke this function. //Reads quiz scores for each student into the two-dimensional array grade //(but the input code is not shown in this display). Computes...
Using C++: Write a function that recursively calculates the sum of an array. The function should...
Using C++: Write a function that recursively calculates the sum of an array. The function should have 2 parameters, the array and an integer showing the number of elements (assume they are all integers) in the array. The function will use a recursive call to sum the value of all elements. You must prompt for a series of integers to be entered in the array. As your program reads the numbers in, increment a count so it knows how many...
Please solve the following problem for MATLAB Write a user-defined function that calculates the average and...
Please solve the following problem for MATLAB Write a user-defined function that calculates the average and the standard deviation of a list of numbers. Use the function to calculate the average and the standard deviation of the following list of grades : 80 75 91 60 79 89 65 80 95 50 81
Your task is to write a program in C or C++ that calculates the total amount...
Your task is to write a program in C or C++ that calculates the total amount of money a person has made over the last year. Your program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based...
Write a program that contains a function that takes in three arguments and then calculates the...
Write a program that contains a function that takes in three arguments and then calculates the cost of an order. The output can be either returned to the program or as a side effect. 1. Ask the user via prompt for the products name, price, and quantity that you want to order. 2. Send these values into the function. 3. Check the input to make sure the user entered all of the values. If they did not, or they used...
In PYTHON A non-governmental organization needs a program to calculate the amount of financial assistance for...
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,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT