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

Hello, this problem has been posted before on Chegg and I copied it just as it i

ID: 3852249 • Letter: H

Question

Hello, this problem has been posted before on Chegg and I copied it just as it is shown, but I repeatedly get an "argumentException" error on one of the lines of code. The error comes from the line with: ----- monthlyPay.Text = -Financial.Pmt(rate / 12, 12 * terms, principal) ------ written in the code. When the error displays there is a red underline underneath the last ) after the word principle. If its possible to redo this problem that would be awesome! The problem is from the "Microsoft Visual Basic 2015 RELOADED 6th edition" book, chapter 7, Case Project "Loan Calculator", page 401. Also, I am a beginner with a beginner's experience in using Visual Basic.

Here is the problem:

Here is the given Interface:

Tools in the interface:

Principle: with TextBox
Annual interest rate (%): with ComboBox
Term (years): with ComboBox
Monthly payment: with Label
Principle and interest: with ListBox
Display = Button
Exit = Button

As always, thank you for your help with this!

Case Projects Loan Calculator Create an application that displays a monthly payment on a loan. The application should also display the amount applied to the loan's principal each month and the amount that represents interest. Use the following names for the solution and project, respectively: Loan Solution and Loan Project. Save the solution in the VbReloaded2015lChapo7 folder. Change the form file's name to Main Form.vb. The application should use annual interest rates from 2% through 10% in increments of 1%, and use terms from 1 through 30 years. You can use the Financial PPmt method to calculate the portion of the payment applied to the principal each month. The method's syntax is Financial .PPmt CRate, Per, NPer, PV). In the syntax, Rate is the interest rate, NPer is the number of payment periods, and PV is the present value of the loan. The Per argument is the payment period for which you want to calculate the portion applied to the principal. The Per argument must be a number from 1 through NPer The method returns the calculated value as a Double number. You can either create your own interface or create the one shown in Figure 7-44; the figure shows a sample run of the application. The combo box that gets the interest rate is the DropDown style. The combo box that gets the term is the DropDownList style. The text box that displays the output has its Multiline and ReadOnly properties set to True and its ScrollBars property set to Vertical (1, 2, 4-7)

Explanation / Answer

Ans: ArgumentException is thrown once method is invoked and minimum of one amongst the passed arguments doesn't meet the parameter specification of called_method.

'frm_Loan

Public Class frmLoan

'clear btn

Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click

' Clears values of the text boxes

' amount

txtAmount.Text = ""

' interest_rate

txtRate.Text = ""

' term

txtDuration.Text = ""

' monthly_payment

txtPayment.Text = ""

End Sub

' calculate

Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click

' checks if invalid enters

' true

If InputIsValid() = True Then

' calculates

CalculateValue()

' if false

Else

' error

MessageBox.Show("please enter data")

End If

' end

End Sub

' boolean

Function InputIsValid() As Boolean

' IF true

Dim blank As Boolean = True

' TRUE

If (radAmount.Checked = True) Then

' if blank

blank = False

' principle amount

ElseIf txtAmount.Text = "" Then

' true   

blank = True

End If

' term

If (radDuration.Checked = True) Then

' false_blank

blank = False

ElseIf txtDuration.Text = "" Then

blank = True

End If

' monthly pay

If (radPayment.Checked = True) Then

' blank

blank = False

' true

ElseIf txtPayment.Text = "" Then

blank = True

End If

' interest rate checked

If (radRate.Checked = True) Then

' false

blank = False

ElseIf txtRate.Text = "" Then

' true

blank = True

End If

' return

Return (blank = False)

' ends functn

End Function

' calculation

Sub CalculateValue()

' if checked

If radAmount.Checked = True Then

' calc

txtAmount.Text = PV(CDbl(txtRate.Text) / 1200, CDbl(txtDuration.Text), -CDbl(txtPayment.Text)).ToString("C")

End If

' calcultn part

' if checked

If radRate.Checked = True Then

txtRate.Text = (1200 * Rate(CDbl(txtDuration.Text), CDbl(txtPayment.Text), -CDbl(txtAmount.Text))).ToString("N1")

End If

' term

' if checked

If radDuration.Checked = True Then

' formula

txtDuration.Text = NPer(CDbl(txtRate.Text) / 1200, CDbl(txtPayment.Text), -CDbl (txtAmount.Text)).ToString("N0")

End If

' monthly payment

' if checked

If radPayment.Checked = True Then

' calculation   

txtPayment.Text = Pmt(CDbl(txtRate.Text) / 1200, CDbl(txtDuration.Text), -CDbl (txtAmount.Text)).ToString("C")

End If

' ends

End Sub

' ends class

End Class