Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Enter the target value: 38 Write a program that uses functions to solve the problem below: Add a function, subsetSum(), to your program that takes
Enter the target value: 38 Write a program that uses functions to solve the problem below: Add a function, subsetSum(), to your program that takes as input a list of positive integers and a positive number target. Your function should display an addition expression of the numbers that add up to the target value and return True if there are three numbers in the list that add Target list entered: [5,4,10,20,15,19] up to target. For example, if the input is list [5,4,10,20,15,19] and the target value is 38 , then the function should display 4+15+19=38 and return True because 4+15+19=38. However, the same input list [5,4,10,20,15,19] and target 10 should not display an addition expression and returns False: Target value entered: 38 1. The program will prompt the user to enter the list and the target value 2. The program will call subsetSum() and pass the list and target value as arguments 4+15+19=38 3. The function will determine whether 3 numbers in the list add up to the target value a. Display an addition expression in the function and return True Function return value: True 4. If three numbers in the list do not add up to the target value a. Function returns False 5. Display the function return value in the program Include the following in your program logic 1. Program prompts for the list and target values 2pts 2. Function subsetSum() is defined with the correct number of parameters 2pts 3. Call the subsetSum() function and pass the list and target values as arguments 1pt 4. Function uses selection structure to determine if 3 numbers in the list add up to the target value or not 5 pts 5. Function displays addition expression 2 pts 6. Function returns True or False 1.5pts 7. Program displays function return value 1.5pts Enter the target value: 10 Target list entered: [5,4,10,20,15,19] Target value entered: 10 Example Program Runs: Example 1 Function return value: False Enter a list containing integers: [5,4,10,20,15,19] Important: If your program does not run, that's an automatic 50% deduction Homework submission details
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started