Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is for Microsoft VBA The user (me) will enter the number of Fibonacci numbers to calculate (N) in cell D4 of Sheet3. Create a

this is for Microsoft VBA The user (me) will enter the number of Fibonacci numbers to calculate (N) in cell D4 of Sheet3. Create a run button in Sheet3 that executes a macro named problem3. This macro completes the following tasks: Create a constant named golden and assign it the value 1.61803398874989. Obtain N from cell D4. If the value of N is less than 3, tell the user that the number is invalid and end the program. Create an array named Fib to store the Fibonacci numbers. The array Fib has N elements. Call a Sub procedure named calcFib to calculate the N Fibonacci numbers and store them in Fib. Here is an example of how to call calcFib in your program: Call calcFib(fib, N) Inside calcFib, store the values 1 and 1 in Fib(1)and Fib(2), then calculate the remaining Fibonacci numbers and store them in Fib. After this is completed, end the calcFib Sub procedure. Back in problem3, output all N Fibonacci numbers to column A. Starting from the third Fibonacci number, calculate the ratio of the current Fibonacci number to the previous Fibonacci number and output that ratio in column B. The first ratio appears in cell B3. Starting from the third Fibonacci number, calculate the percent difference of each Fibonacci number ratio to the actual value of the golden ratio and output the percent difference in column C. The first percent difference appears in cell C3. You can calculate the percent difference using the following formula: The percent difference should be calculated using a Function procedure named pdiff. Here is an example of how to use pdiff in your macro: ans = pdiff(fibratio, golden) For example, if the user inputs 5 in D4 and then clicks the run button, the first five rows should have the following data in columns A, B, and C: 1 1 2 2.000 23.6068 3 1.500 -7.2949 5 1.667 3.0057 Clear all data in columns A-C before outputting the data to Sheet3. If you dont, you may have a lot of extra data on your screen after running your program. For example, try running your program with N = 20, then lower the value of N to 5 and rerun the program. If you do not clear your data from the previous run, there will be a lot of extra lines of output leftover. See problem 2 from homework 4 for a discussion on how to complete this task. Use Option Explicit for this macro. Highlight and label the cell where the user must input data. Assume the user will input a number in D4 before clicking the run button.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions