Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ME309 Mid-Term VBA Coding Exam 1,2,3,69 V S 3/15/2017 7:00-9:45 pm 35, 9, S. 1.

ID: 3168322 • Letter: M

Question

ME309 Mid-Term VBA Coding Exam 1,2,3,69 V S 3/15/2017 7:00-9:45 pm 35, 9, S. 1. () VBA code to greatest common factor (GCF) and the least common 60 pointswrite a find the multiple (LCM) of two arbitrary positive integers. For example, the GCF and LCM of 45 and 18 are 9 and 90, respectively. Specific requirements: Request two arbitrary positive integers from input box; 2) Calculate the greatest common factor and the common multiple for the two input integers; 3) Returm your least result via message box. NC0 points) write a VBA code to calculate the average value of all prime numbers between 1 and 0. Return your result in a message box. : intA prime number is a natural number greater than 1 that has no positive integer factors other than numbers between 20 , 3, , 7, 13, and 19. 1 and itself. The prime 1 and are: 2511, 17 (40 points) Write a VBA code to implement Cramer's rule, then apply your code to solve below system of linear equations: S 14042 113 2 1-2 3-1 3 -1 2-2 13x3-2 -3 1 0 2 1 1 2 22 1-3 2 J Lx, l Specific requirements: W Input the coefficient matrix and constant vector in spreadsheet, then select and read the coefficient matrix and constant vector from spreadsheet 2 existence, if solution not exits, please prompt a message Solution not exits " then stop the calculations return solution vector to spreadsheet your code can be used to solve any system of linear equations. matrix Hint: you can use "Application. WorksheetFunctionMDetermA)" to find the determinant of [A]. SUBMIT YOUR VBA CODES IN THREE SEPARATE EXCEL FILES VIA MOODLE

Explanation / Answer

2)

Private Sub cmdPrime_Click()
Dim p, n, i As Integer
p = 1
Print “Prime Numbers are : ”
For n = 1 To 100
For i = 2 To n – 1
If n Mod i = 0 Then
p = 0
Exit For
Else
p = 1
End If

Next
If p = 1 Then
Print n
End If

Next
End Sub