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

please assist with this question, thank you. In this lab, you complete a partial

ID: 3772133 • Letter: P

Question

please assist with this question, thank you.

In this lab, you complete a partially written Visual Basic program that includes a function that returns a value. The program is a simple calculator that prompts the user for two numbers and an operator (+, , *, /, or ). The two numbers and the operator are passed to the function where the appropriate arithmetic operation is performed. The result is then returned to the Main() procedure where the arithmetic operation and result are displayed. For example, if the user enters 3, 4, and *, the following is displayed:

3.00 * 4.00 = 12.00

The source code file provided for this lab includes the necessary variable declarations, and input and output statements. Comments are included in the file to help you write the remainder of the program.

1. Open the source code file named Calculator.vb using Notepad or the text editor of your choice.

2. Write the Visual Basic statements as indicated by the comments.

3. Save this source code file in a directory of your choice, and then make that directory your working directory.

4. Compile the source code file Calculator.vb.

5. Execute the program.

' Calculator.vb - This program performs arithmetic, ( +. -, *. /, ) on two numbers.
' Input: Interactive
' Output: Result of arithmetic operation

Module Calculator
Sub Main()
Dim NumberOne As Double
Dim NumberTwo As Double   
Dim NumberOneString As String
Dim NumberTwoString As String
Dim Operation As String
Dim Result As Double  
                      
NumberOneString = InputBox$("Enter the first number: ")
NumberOne = Convert.ToInt32(NumberOneString)
NumberTwoString = InputBox$("Enter the second number: ")
NumberTwo = Convert.ToInt32(NumberTwoString)
Operation = InputBox$("Enter an operator (+.-.*,/,): ")
      
' Call performOperation function here      
  

System.Console.Write(NumberOne)
System.Console.Write(" " & Operation & " ")
System.Console.Write(NumberTwo)
System.Console.Write(" = ")
System.Console.WriteLine(Result)
End Sub ' End of Main() procedure
  
  
' Write performOperation function here

End Module ' End of Calculator module

Explanation / Answer

I have added code for performOperation function inside the main block.. Please check

Module Calculator
Sub Main()
Dim NumberOne As Double
Dim NumberTwo As Double
Dim NumberOneString As String
Dim NumberTwoString As String
Dim Operation As String
Dim Result As Double
                    
NumberOneString = InputBox$("Enter the first number: ")
NumberOne = Convert.ToInt32(NumberOneString)
NumberTwoString = InputBox$("Enter the second number: ")
NumberTwo = Convert.ToInt32(NumberTwoString)
Operation = InputBox$("Enter an operator (+.-.*,/,): ")
    
' Call performOperation function here    
performOperation(NumberOne,NumberTwo,Operation)

System.Console.Write(NumberOne)
System.Console.Write(" " & Operation & " ")
System.Console.Write(NumberTwo)
System.Console.Write(" = ")
System.Console.WriteLine(Result)
End Sub ' End of Main() procedure


' Write performOperation function here
public function performOperation(ByVal NumberOne,Byval NumberTwo,Byval operation)
   if (operation="+")
   {
   result=NumberOne+NumberTwo  
   else if (operation="*")
   {
   result=NumberOne*NumberTwo  
   else if (operation="-")
   {
   result=NumberOne-NumberTwo
    else if (operation="/")
   {
   result=NumberOne/NumberTwo
   else if (operation="")
   {
   result=NumberOneNumberTwo
   end if
   end if
   end if
   end if
   end if
   }
   }
   }
   msgbox result
   }

end function()

End Module ' End of Calculator module