Please assist with this question please. thank you. Lab 9-3: Writing Procedures
ID: 3772131 • Letter: P
Question
Please assist with this question please. thank you.
Lab 9-3: Writing Procedures that Require Multiple Parameters
In this lab, you complete a partially written Visual Basic program that includes procedures that require multiple parameters (arguments). The program prompts the user for two numeric values. Both values should be passed to procedures named calculateSum(), calculateDifference(), andcalculateProduct(). The procedures compute the sum of the two values, the difference between the two values, and the product of the two values. Each procedure should perform the appropriate computation and display the results. The source code file provided for this lab includes the variable declarations and the input statements. Comments are included in the file to help you write the remainder of the program.
1. Open the source code file named Computation.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 Computation.vb.
5. Execute the program.
' Computation.vb - This program calculates sum, difference, and product of two values.
' Input: Interactive
' Output: Sum, difference, and product of two values.
Module Computation
Sub Main()
Dim Value1 As Double
Dim Value1String As String
Dim Value2 As Double
Dim Value2String As String
Value1String = InputBox$("Enter first numeric value: ")
Value1 = Convert.ToDouble(Value1String)
Value2String = InputBox$("Enter second numeric value: ")
Value2 = Convert.ToDouble(Value2String)
// Call calculateSum() here
// Call calculateDifference() here
// Call calculateProduct() here
End Sub ' End of Main() procedure
' Write calculateSum procedure here.
' Write calculateDifference procedure here.
' Write calculateProduct procedure here.
End Module ' End of Computation module
Explanation / Answer
' Computation.vb - This program calculates sum, difference, and product of two values.
' Input: Interactive
' Output: Sum, difference, and product of two values.
Module Computation
Sub Main()
Dim Value1 As Double
Dim Value1String As String
Dim Value2 As Double
Dim Value2String As String
Value1String = InputBox$("Enter first numeric value: ")
Value1 = Convert.ToDouble(Value1String)
Value2String = InputBox$("Enter second numeric value: ")
Value2 = Convert.ToDouble(Value2String)
// Call calculateSum() here
// Call calculateDifference() here
// Call calculateProduct() here
System.Console.WriteLine(calculateSum(Value1, Value2))
System.Console.WriteLine(calculateDifference (Value1, Value2))
System.Console.WriteLine(calculateProduct (Value1, Value2))
End Sub ' End of Main() procedure
' Write calculateSum procedure here.
Public Function calculateSum(ByVal value1 As Double, ByVal value2 As Double) As Double
calculateSum = value1 + value2
End Function
' Write calculateDifference procedure here.
Public Function calculateDifference(ByVal value1 As Double, ByVal value2 As Double) As Double
calculateDifference = value1 - value2
End Function
' Write calculateProduct procedure here.
Public Function calculateProduct(ByVal value1 As Double, ByVal value2 As Double) As Double
calculateProduct = value1 * value2
End Function
End Module ' End of Computation module