Question: Course: Applied OO Programming Part 1 : Add a function, subsetSum(), to your program that takes as input a list of positive integers and a

Course: Applied OO Programming

Part 1 :

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 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 return False:

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

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

4. If there 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

2. Function subsetSum() is defined with the correct number of parameters

3. Call the subsetSum() function and pass the list and target values as arguments

4. Function uses selection structure to determine if 3 numbers in the list add up to the target value or not

5. Function displays addition expression

6. Function returns True or False

7. Program displays function return value

Part 2 :

Add a function, statement(), that takes a list of positive and negative floating point numbers representing deposits and withdrawals. The function will use the values from the list containing deposits and withdrawal to create and return a new two-dimensional list containing two sublists: One list containing all deposits and another list containing withdrawals. The program will display the list returned from the function.

The program will prompt the user for the list containing positive and negative floating-point numbers. The list will be passed to the statement() function as an argument.

Include the following in your program logic

1. Prompt the user to enter the list containing positive and negative floating-point numbers .

2. Define the statement() function with the correct number of parameters

3. Add logic to the function for the following. a. creates a new list containing two sub lists b. Return the new list

4. Call the function

5. Display the function return value .

Part1 Examples:

Example 1

Enter a list containing integers: [5, 4, 10, 20, 15, 19] Enter the target value: 38 Target list entered: [5, 4, 10, 20, 15, 19] Target value entered: 38 4 + 15 + 19 = 38 Function return value: True

Example 2

Enter a list containing integers: [5, 4, 10, 20, 15, 19] Enter the target value: 10 Target list entered: [5, 4, 10, 20, 15, 19] Target value entered: 10 Function return value: False

Part2 Example:

Enter a list containing bank transactions: [-5.99, 35, 95, 29.63, -17.00, 120.00, 200, -13.50]

List containing two lists of the tranactions: [[35, 95, 29.63, 120.0, 200], [-5.99, -17.0, -13.5]]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!