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

INSTRUCTIONS VISUAL BASICS Write a program that displays a menu with the followi

ID: 3674608 • Letter: I

Question

INSTRUCTIONS VISUAL BASICS

Write a program that displays a menu with the following choices to the user:

1.) Count to “x”

2.) Count Some More (module level variable)

3.) Count Some More (static variable)

4.) Multiply Numbers (pass by value)

5.) Multiply Numbers (pass by reference)

6.) Exit Program

After the menu has been displayed get a selection from the user. Make sure the selection is valid and re-prompt the user if necessary. After a selection has been made, call a function or subroutine that implements each of the features on the menu. There should be one function or subroutine per feature. After a feature has been executed, redisplay the menu until the exit feature is chosen.

Feature 1 - Count to “x” - Write a function that declares a variable with procedural level scope and uses it to display the numbers 1 through x on the screen. Use a looping structure to iterate through the values. When this option is selected, the program should ask the user how high to count before calling the procedure. Pass the value into the procedure as an argument.

Feature 2 - Count Some More (module level variable) - Create a variable with module level scope in your program. Initialize it to a value of 1. Every time the count some more feature is called, the program should display the next 10 successive integers on the screen. Since the variable was declared with module level scope, the numbers should get higher and higher every time the feature is called.

Feature 3 - Count Some More (static variable) - This function behaves in the exact same manner as Feature 2 except the variable being used to count should be declared as a static within the procedure.

Feature 4 - Multiply Numbers (pass by value) - When this feature is executed, the user should be prompted for two numbers. The numbers are passed into the function though a pass-by-value mechanism. The function should display a neat multiplication problem on a single line indicating the values in the two factors and the product. The product should be returned by the procedure.

Feature 5 - Multiply Numbers (pass by reference) - This feature should behave in the exact same manner as feature 4 except the multiplication problem is not displayed within the body of the procedure. Instead, two factors are passed into the function as pass-by-value variables, and a single result variable is passed in through the pass-by-reference mechanism. The product of the two factors is stored. The driver procedure should contain the code that displays the result of the multiplication problem.

Feature 6 - Exit Program - This feature should cause the program to exit.

SOLUTION

<Place your solution here. Please make sure your IDE is set to font Courier New (10pt) before you copy/paste>

Explanation / Answer

Module Module1
Public m As Integer = 0
Public Sub countx(ByVal x As Integer)
For i = 1 To x
Console.WriteLine(i)
Next
End Sub
Public Sub countmore()
For i = 1 To 10
m = m + 1
Console.WriteLine(m)
Next
End Sub

Public Sub countmores()
Static x As Integer
For i = 1 To 10
x = x + 1
Console.WriteLine(x)
Next
End Sub
Public Function multiply(ByVal a1 As Integer, ByVal b1 As Integer) As Integer
Return a1 * b1
End Function
Public Function multiplyr(ByRef a1 As Integer, ByRef b1 As Integer) As Integer
Return a1 * b1
End Function
Sub Main()
Dim a, x, a1, b1, c1 As Integer
While (True)
Console.WriteLine("1. Count to x")
Console.WriteLine("2. Count Some More (Module level variable")
Console.WriteLine("3. Count Some More (static variable")
Console.WriteLine("4. Multiply Numbers(pass by value")
Console.WriteLine("5. Multiply Numbers(pass by reference")
Console.WriteLine("6. Exit Program")

a = Convert.ToInt32(Console.ReadLine())

If a = 1 Then
Console.WriteLine("How high to count")
x = Convert.ToInt32(Console.ReadLine())
countx(x)
End If

If a = 2 Then

countmore()
End If
If a = 3 Then

countmores()
End If

If a = 4 Then
Console.WriteLine("Enter number")
a1 = Convert.ToInt32(Console.ReadLine())
Console.WriteLine("Enter number")
b1 = Convert.ToInt32(Console.ReadLine())
c1 = multiply(a1, b1)
Console.WriteLine("Multiplication is " & c1)
End If

If a = 5 Then
Console.WriteLine("Enter number")
a1 = Convert.ToInt32(Console.ReadLine())
Console.WriteLine("Enter number")
b1 = Convert.ToInt32(Console.ReadLine())
c1 = multiplyr(a1, b1)
Console.WriteLine("Multiplication is " & c1)
End If
If a = 6 Then
End
End If
End While
End Sub

End Module

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote