Examlex

Solved

Problems - Correcting Logic and Code Errors

question 24

Essay

Problems - Correcting Logic and Code Errors
The following sample of code contains errors. Rewrite the incorrect statements to correct all errors.
Public Class Truck
Private Property Miles As Decimal
Public Function New()
_Miles = 0
End Function
Public Sub New(ByVal decM As Decimal)
Miles = decM
End Sub
Public Overrider Function GetMPG() As Decimal
'returns the miles per gallon for a truck
Return _Miles / 30
End Function
End Class
'derived class
Public Class Car
Receives Truck
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal decM As Decimal)
MyBase.New(decM)
End Sub
Public Function GetMPG() As Decimal
Return _Miles / 18
End Function
End Class


Definitions:

Present Value

The equivalent value today of cash flows or a sum of money anticipated in the future, using a predetermined return rate.

Annuity

A financial product that pays out a fixed stream of payments to an individual, primarily used as an income stream for retirees.

Interest Rate

Interest rate is the percentage charged by a lender to a borrower for the use of assets, adjusting for the cost of credit or the return on investment.

Lump Sum

A single payment made at a particular time, as opposed to several smaller installments.

Related Questions