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.
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...
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...
Write a MIPS assembly language procedure that implements the Towers of Hanoi recursive function given the...
Write a MIPS assembly language procedure that implements the Towers of Hanoi recursive function given the following declaration: void towers(int n, char source, char dest, char spare); The function outputs a message describing each move. The source, destination, and spare poles are indicated with a character identifier of your choosing ('A', 'B', 'C' are common). Write a MIPS assembly language program that demonstrates the Towers of Hanoi procedure. Your program should ask the user for the number of disks. The...
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...
Question 1 The binomial formula has two parts. The first part of the binomial formula calculates...
Question 1 The binomial formula has two parts. The first part of the binomial formula calculates the number of combinations of X successes. The second part of the binomial formula calculates the probability associated with the combination of success and failures. If N=4 and X=2, and p = .5, what is that probability from the second part of the formula? Group of answer choices .0625 .5 .3750 .1563 Question 2 Normal Distribution Problem. The birth weight is of newborn babies...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT