the following Sub calculates the present value of a future amount: Sub ComputePr
ID: 3537897 • Letter: T
Question
the following Sub calculates the present value of a future amount:
Sub ComputePresentValue(ByVal FValue As Single, ByVal Years As Integer, ByVal Rate As Single, ByRef PValue As Single)
PValue = FValue/(1 + Rate/100)^Years
End Sub
Write a few lines of code to call this Sub and to display the present value of future amount of $1000 in 10 years at the rate of 5% (Note: In this question, you don't have to give me the present value, just a few lines of code used to call this Sub and display the present value)
Answer
What is the display by the message box (in line 5) when Sub Main is executed?
1. Sub Main()
2. Dim X1 As Short = 5
3. Dim X2 As Short = 10
4. Call DoubleTheNumber(X1,X2)
5. Msgbox (X1 & "," & X2)
6. End Sub
Sub DoubleTheNumber(ByVal X1 As Short, ByRef X2 As Short)
X1 = 2*X1
X2 = 2*X2
End Sub
what is the display in the message box (line 7) in the following code?
1. Sub Main()
2. Dim X1 As Integer = 5
3. Dim X2 As Integer = 10
4. Dim X3 As Integer = 15
5. Dim X4 As Integer = 20
6. Call Transform(X1, X2, X3, X4)
7. MsgBox(X3 & %u201C,%u201D & X4)
8. End Sub
Sub Transform(ByVal Y1 as Integer, ByVal Y2 As Integer, ByVal Y3 As Integer, ByRef Y4 As Integer)
Y3 = Y1*Y2
Y4 = Y2*Y3
End Sub
What is the display in the message box on line 6 in the following code?
1. Sub Main()
2. Dim X1 As Integer = 3
3. Dim X2 As Integer = 4
4. Dim X3 As Integer
5. X3 = (ZZ(X1,X2))^2
6. MsgBox(X3)
7. End Sub
8. Function ZZ(ByVal Y1 As Integer, ByVal Y2 As Integer) As Integer
9. Return(Y1+1)*(Y2+1)
10. End Sub
Write a function to calculate the depreciation of an asset with Original Value OV, Salvage Value SV and Useful Life UL. UL must be an integer, OV and SV may contain fractional values. (Note: in case you don't know, Depreciation is (Original Value minus Salvage Value)/Useful Life)
Write one line of code to display the depreciation for an asset with an original value of $12,000, a salvage value of $3,000 and a useful life of 5 years, using the above function. The display should read like this:
The depreciation value is xxxxxx
where xxxxxx is the depreciation value calculated using your function.
Write a Sub to calculate the depreciation of an asset with Original Value OV, Salvage Value SV and Useful Life UL. UL must be an integer, OV and SV may contain fractional values. (Note: in case you don't know, Depreciation is (Original Value minus Salvage Value)/Useful Life)
Answer
Write a few lines of code to compute and display the depreciation for an asset with an original value of $10,000, a salvage value of $2,000 and a useful life of 8 years, using the above Sub. The display should read like this:
The depreciation value is xxxxxx
where xxxxxx is the depreciation value calculated using your sub.
What two things are wrong with the following sub?
Sub AreaOfTriangle(ByVal Base As Single, ByVal Height As String, ByVal Area As Short) As Single
Area=0.5*Base*Height
End Sub
the following Sub calculates the present value of a future amount:
Sub ComputePresentValue(ByVal FValue As Single, ByVal Years As Integer, ByVal Rate As Single, ByRef PValue As Single)
PValue = FValue/(1 + Rate/100)^Years
End Sub
Write a few lines of code to call this Sub and to display the present value of future amount of $1000 in 10 years at the rate of 5% (Note: In this question, you don't have to give me the present value, just a few lines of code used to call this Sub and display the present value)
Answer
Explanation / Answer
Sub ComputePresentValue(ByVal FValue As Single, ByVal Years As Integer, ByVal Rate As Single, ByRef PValue As Single) Dim Fvalue As integer = 1000 Dim Rate As Integer = 5 Dim Years As Integer = 10 Dim Pvalue As Double PValue = FValue/(1 + Rate/100)^Years Msgbox(Pvalue) End Sub 2)Msgbox of line 5 displays (10,20) 3)Msgbox of line7 displays (50,2011,2013,150) 4)Msgbox of line 6 displays 400
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.