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

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.
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...
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
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...
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 calculates the amount a person would earn over a period of time...
Write a program that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should display a table showing the salary for each day, and then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the number of pennies. Input Validation: Do not...
Python code Financial Assistance : A non-governmental organization needs a program to calculate the amount of...
Python code 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...
A non-governmental organization needs a program to calculate the amount of financial assistance for needy families....
A non-governmental organization needs a program to calculate the amount of financial assistance for needy families. The formula is as follows:5 pts If the annual household income is between $30,000 and $39,999 and the household has at least three children, the amount is $1000 per child. If the annual household income is between $20,000 and $29,999 and the household has at least two children, the amount is $1500 per child. If the annual household income is less than $20,000, the...
7. Finding Roots Using the Bisection Method Write a function that implements the "bisection method" for...
7. Finding Roots Using the Bisection Method Write a function that implements the "bisection method" for finding the roots of function. The signature of your function should look like def find_root(f,a,b,n): where n is the maximum number of iterations of to search for the root. The code should follow this algorithm: We are given a continuous function f and numbers a and b and with a<b with f(a)<0<f(b). From the intermediate value theorem we know that there exists a c...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT