Question: 1. This problem will give you practice using a Do/While loop in VBA by solving a packing problem. Imagine you have a collection of blocks


1. This problem will give you practice using a Do/While loop in VBA by solving a packing problem. Imagine you have a collection of blocks where each block has a different size. One block is 1 unit in size one block is 2 units in size, one block is 3 units in size, etc. If someone gives you a container of size S you want to know how many blocks you can fit into the container if you start your packing with the smallest and work our way towards the bigger blocks. To solve this problem, write a VBA function called "Packing" that allows the user to specify a container size (a positive number). For this size, your function should return the largest number n where the sum 1 +2+ n is no larger than than the specified container size. Your function should have the following general form 1. Begin by assuming that n is 0 2. Also, assume that the sum is initially O 3. Set up a Do/While loop that iterates while the sum does not exceed the specified size 4. Inside the loop, increase n by 1 (e.g., n n+ 1) 5. Also inside the loop, update the sum to include the new n value 6. Your loop will stop only when n is too large, so after the loop, subtract one from n Include comments in your function that explain how it works. You can verify that your function is working by trying these cases. If the size is 6, then n 3. If the size is 40, then n8. When your function is working, use it to find the values of n for the sizes given on the Problem 3 page of the Excel file and make an x-y scatter plot for the value of n (on the y axis) for limits between 30 and 100 (on the x axis
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
