Hello I am relatively new to this forum.
I am currently stuck at these three problems and it would be very helpful if someone can help me on them.
1.Write a Function named GetsBigger that has a parameter n. This function uses a For loop to generate n random numbers, (e.g., x = Rnd) and calculates and returns how many times the new random number is bigger than the biggest random number generated so far. Hint: Inside the function, have variables for (a) the current random number, (b) the biggest random number seen so far, and (c) a count of how many times the current random number is bigger than the biggest so far. Each iteration of the loop updates these variables as necessary. Hint: Use an appropriate If statement (I used the form with no Else; also, see the subroutines and function in the workbook Lecture 26 for "Calculating Pi", which has all the VB elements needed for this function. Note that GetsBigger(1) should return 1 I have called that function in column A of the GetsBigger worksheet. The result shows as #NAME? until you define the function. For 100,000 numbers, the average (calculate by cell A12) should be about 13.
2.Write a Function named RowSum that has three parameter row, startC, and stopC. This function uses a For loop to generate values from all the column cells in the specfied row (between startC and stopC) and calculates and returns the sum of these values. Hint: Set a result variable equal to 0 and then increment it inside the loop, adding the value in each cell visited. I have called that function in column A of the Stats worksheet, for all columns in rows 1 and 2 (in cells A5 and A6) and for columns 3 through 6 in rows 1 and 2 (in cells A8 and A9). The result shows as #NAME? until you define the function.
3.Write a Function named RowMax that has three parameter row, startC, and stopC. This function uses a For loop to generate values from all the column cells in the specfied row (between startC and stopC) and calculates and returns the maximum(biggest) of these values. Hint: Set a result variable equal to the value in cell specified by row and startC and look at every other cell value in that row, updating the result to that value if it is bigger. I have called that function in column B of the Stats worksheet, for all columns in rows 1 and 2 (in cells B5 and B6) and for columns 3 through 6 in rows 1 and 2 (in cells B8 and B9). The result shows as #NAME? until you define the function.
Bookmarks