Question

6. Loan Calculator The e most common types of loans are mortgage loans, which are tinance the purchase of a house, and car loans. A loan consists of four com- L1 ponents--amount, interest rate, duration, and periodic payment. The purpose values of the other three components. prograrmming project is to calculate the value of any one of the components given the We will ascurme that the duration is in months, that interest (given as a percent) i gages typically have an interest rate of about 4% and a duration o months). Car loans typically have between 3 and 5 years (36 to 60 months). monthly, and that payments are made monthly. Currently home mort- f 30 years (360 an interest rate of about 6% and a duration of Four built-in Visual Basic financial functions that perform loan calculations are as follows Pmt(interest rate / 1200, duration, -amount) gives 1200Rate(duration, monthly payment, -amount) gives the stated interest rate PV(interest rate/1200, duration, -monthly payment) gives NPer(interest rate/1200, monthly paymen the monthly payment the amount of the loan t, -amount) gives the duration of the loan in months Write a program in which the user specifies a val lue to calculate, enters the three other values, and clicks on the Calculate Value button. See Fig 5.16. Before any calcula- tions are made, the program should usea button is selected and that the values entered into the three text boxes corresponding to unselected radio buttons are valid. Function procedure to validate that a radio Annuity Check Value to Calculate Loan Calculator- Check Value to Calculate O Amount of loan O Interest rate (annual) O Duration of loan in months 36 × O Present value 1000 Interest rate per period 0025 O Number of payments60 14500 O Periodic payment 100 Future value $7626 29 Monthly payment 443.75 Calculate Value Calculate Value Clear All Values Clear All Values Possible outcome of Programming Project 6. FIGURE 5.46 FIGURE 5.47 Possible outcome of Programming Project 7
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot

Public Class frmLoanCalculator Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.cl Dim dblResult As Double If rdbLoanAmount.Checked Then If isValid(e) -True Then Loan Amount Calculation db!Result = PV(txtInterestRate . Text / 1200, txtDuration·Text, txtMonthlyPmt txtLoanAmount.TextMath.Round(dblResult) End If ElseLoan Calculator Check Value to Calculate xt, txtMonthlyPmt.Text, lt, #.0) txtLoanAmount O Amount of oan ○ Interest rate (annual 。Duration of loan in months O Monthly payment 14500 6.4 Else! |36 / 1200, txtMonthlyPmt.Text, txtLoanAmc 443.75 Celculate Value Else Cear All Values

---------------------------------------------------------

program

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

        Dim dblResult As Double
        If rdbLoanAmount.Checked Then
            If isValid(0) = True Then
                'Loan Amount Calculation
                dblResult = PV(txtInterestRate.Text / 1200, txtDuration.Text, txtMonthlyPmt.Text * -1)
                txtLoanAmount.Text = Math.Round(dblResult)
            End If
        ElseIf rdbInterestRate.Checked Then
            If isValid(1) = True Then
                'Interest Rate Calculation
                dblResult = 1200 * Rate(txtDuration.Text, txtMonthlyPmt.Text, txtLoanAmount.Text * -1)
                txtInterestRate.Text = Format(dblResult, "#.0")
            End If
        ElseIf rdbDuration.Checked Then
            If isValid(2) = True Then
                'Duration Calculation
                dblResult = NPer(txtInterestRate.Text / 1200, txtMonthlyPmt.Text, txtLoanAmount.Text * -1)
                txtDuration.Text = CInt(dblResult)
            End If
        ElseIf rdbMonthlyPmt.Checked Then
            If isValid(3) = True Then
                'Monthly Payment Calculation
                dblResult = Pmt(txtInterestRate.Text / 1200, txtDuration.Text, txtLoanAmount.Text * -1)
                txtMonthlyPmt.Text = Format(dblResult, "#.00")
            End If
        End If
    End Sub

    Private Function isValid(index As Integer) As Boolean
        Select Case index
            Case 0      'Calculation of Loan Amount
                If Len(txtInterestRate.Text) = 0 Then
                    MsgBox("Please enter the Interest Rate!!!")
                    txtInterestRate.Select()
                    Return False
                ElseIf Len(txtDuration.Text) = 0 Then
                    MsgBox("Please enter the Duration!!!")
                    txtDuration.Select()
                    Return False
                ElseIf Len(txtMonthlyPmt.Text) = 0 Then
                    MsgBox("Please enter the Monthly Payment Amount!!!")
                    txtMonthlyPmt.Select()
                    Return False
                ElseIf IsNumeric(txtInterestRate.Text) = False Then
                    MsgBox("Please enter valid Interest Rate!!!")
                    txtInterestRate.Select()
                    Return False
                ElseIf IsNumeric(txtDuration.Text) = False Then
                    MsgBox("Please enter valid Duration!!!")
                    txtDuration.Select()
                    Return False
                ElseIf IsNumeric(txtMonthlyPmt.Text) = False Then
                    MsgBox("Please enter valid Monthly Payment Amount!!!")
                    txtMonthlyPmt.Select()
                    Return False
                End If
            Case 1 'Calculation of Interest Rate
                If Len(txtLoanAmount.Text) = 0 Then
                    MsgBox("Please enter the Loan Amount!!!")
                    txtLoanAmount.Select()
                    Return False
                ElseIf Len(txtDuration.Text) = 0 Then
                    MsgBox("Please enter the Duration!!!")
                    txtDuration.Select()
                    Return False
                ElseIf Len(txtMonthlyPmt.Text) = 0 Then
                    MsgBox("Please enter the Monthly Payment Amount!!!")
                    txtMonthlyPmt.Select()
                    Return False
                ElseIf IsNumeric(txtLoanAmount.Text) = False Then
                    MsgBox("Please enter valid Loan Amount!!!")
                    txtLoanAmount.Select()
                    Return False
                ElseIf IsNumeric(txtDuration.Text) = False Then
                    MsgBox("Please enter valid Duration!!!")
                    txtDuration.Select()
                    Return False
                ElseIf IsNumeric(txtMonthlyPmt.Text) = False Then
                    MsgBox("Please enter valid Monthly Payment Amount!!!")
                    txtMonthlyPmt.Select()
                    Return False
                End If
            Case 2      'Calculation of Loan Duration
                If Len(txtLoanAmount.Text) = 0 Then
                    MsgBox("Please enter the Loan Amount!!!")
                    txtLoanAmount.Select()
                    Return False
                ElseIf Len(txtInterestRate.Text) = 0 Then
                    MsgBox("Please enter the Interest Rate!!!")
                    txtInterestRate.Select()
                    Return False
                ElseIf Len(txtMonthlyPmt.Text) = 0 Then
                    MsgBox("Please enter the Monthly Payment Amount!!!")
                    txtMonthlyPmt.Select()
                    Return False
                ElseIf IsNumeric(txtLoanAmount.Text) = False Then
                    MsgBox("Please enter valid Loan Amount!!!")
                    txtLoanAmount.Select()
                    Return False
                ElseIf IsNumeric(txtInterestRate.Text) = False Then
                    MsgBox("Please enter valid Interest Rate!!!")
                    txtInterestRate.Select()
                    Return False
                ElseIf IsNumeric(txtMonthlyPmt.Text) = False Then
                    MsgBox("Please enter valid Monthly Payment Amount!!!")
                    txtMonthlyPmt.Select()
                    Return False
                End If
            Case 3      'Calculation of Monthly Payment
                If Len(txtLoanAmount.Text) = 0 Then
                    MsgBox("Please enter the Loan Amount!!!")
                    txtLoanAmount.Select()
                    Return False
                ElseIf Len(txtInterestRate.Text) = 0 Then
                    MsgBox("Please enter the Interest Rate!!!")
                    txtInterestRate.Select()
                    Return False
                ElseIf Len(txtDuration.Text) = 0 Then
                    MsgBox("Please enter the Duration!!!")
                    txtDuration.Select()
                    Return False
                ElseIf IsNumeric(txtLoanAmount.Text) = False Then
                    MsgBox("Please enter valid Loan Amount!!!")
                    txtLoanAmount.Select()
                    Return False
                ElseIf IsNumeric(txtInterestRate.Text) = False Then
                    MsgBox("Please enter valid Interest Rate!!!")
                    txtInterestRate.Select()
                    Return False
                ElseIf IsNumeric(txtDuration.Text) = False Then
                    MsgBox("Please enter valid Duration!!!")
                    txtDuration.Select()
                    Return False
                End If
        End Select
        Return True
    End Function

    Private Sub rdbLoanAmount_CheckedChanged(sender As Object, e As EventArgs) Handles rdbLoanAmount.CheckedChanged
        'Makes Loan Amount Text box as readonly
        txtLoanAmount.ReadOnly = True
        txtInterestRate.ReadOnly = False
        txtDuration.ReadOnly = False
        txtMonthlyPmt.ReadOnly = False
        clearAll()
    End Sub

    Private Sub rdbInterestRate_CheckedChanged(sender As Object, e As EventArgs) Handles rdbInterestRate.CheckedChanged
        'Makes Interest Rate Text box as readonly
        txtLoanAmount.ReadOnly = False
        txtInterestRate.ReadOnly = True
        txtDuration.ReadOnly = False
        txtMonthlyPmt.ReadOnly = False
        clearAll()
    End Sub

    Private Sub rdbDuration_CheckedChanged(sender As Object, e As EventArgs) Handles rdbDuration.CheckedChanged
        'Makes Duration Text box as readonly
        txtLoanAmount.ReadOnly = False
        txtInterestRate.ReadOnly = False
        txtDuration.ReadOnly = True
        txtMonthlyPmt.ReadOnly = False
        clearAll()
    End Sub

    Private Sub rdbMonthlyPmt_CheckedChanged(sender As Object, e As EventArgs) Handles rdbMonthlyPmt.CheckedChanged
        'Makes Monthly Payment Amount Text box as readonly
        txtLoanAmount.ReadOnly = False
        txtInterestRate.ReadOnly = False
        txtDuration.ReadOnly = False
        txtMonthlyPmt.ReadOnly = True
        clearAll()
    End Sub

    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
        'Clears all text boxes and makes first radio button as selected
        clearAll()
        rdbLoanAmount.Checked = True
        txtInterestRate.Select()
    End Sub

    Private Sub frmLoanCalculator_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'Select first radio as selected default
        rdbLoanAmount.Checked = True
        txtInterestRate.Select()
    End Sub
    Private Sub clearAll()
        'Clears all text boxes
        txtDuration.Text = ""
        txtInterestRate.Text = ""
        txtLoanAmount.Text = ""
        txtMonthlyPmt.Text = ""
    End Sub
End Class

Add a comment
Know the answer?
Add Answer to:
6. Loan Calculator The e most common types of loans are mortgage loans, which are tinance...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Program Specification: This project involves implementing a Java program that performs a calculation of payments associated...

    Program Specification: This project involves implementing a Java program that performs a calculation of payments associated with loans. The program shall allow a user to enter the following data: annual interest rate the loan (i.e. , number of years), and the loan amount. A GUI like the one below must be used. Loan Calculator Annual Interest Rate: Number of Years Loan Amount: Monthly Payment Total Payment Calculate When the user presses the calculate button, the monthly payment and total amount...

  • USE Javascript. Loan Calculator: Three input boxes for annual interest rate, number of years, and...

    USE Javascript. Loan Calculator: Three input boxes for annual interest rate, number of years, and loan amount for user input. Display the output monthly payment and total payment also to input boxes. Add the Reset button to clear all text boxes after the Compute Payment button.

  • You need to borrow $200,000. E-Click loans will make a 30 year, fully amortizing mortgage loan...

    You need to borrow $200,000. E-Click loans will make a 30 year, fully amortizing mortgage loan with monthly payments, with no points at an interest rate of 8%. (a) Construct a loan amortization schedule for the first 4 months of the loan. (b) What is the principal amount of your loan outstanding after 7 years (84 months) of making payments? Show that you can determine this by finding the FV of the loan after 7 years. Highlight your final answer

  • 8. Calculating an installment loan payment using simple interest Calculating the Loan Payment on a Simple-Interest...

    8. Calculating an installment loan payment using simple interest Calculating the Loan Payment on a Simple-Interest Installment Loan Instaliment loans allow borrowers to repay the loan with periodic payments over time. They are more common than single-payment loans because it is easier for most people to pay a fixed amount periodically (usually monthly) than budget for paying one big amount in the future. Interest on installment loans may be computed using the simple interest method or the add-on method. For...

  • MATLAB!!! CAN SOMEONE SOLVE THIS PROBLEM ON MATLAB?? THANK YOU PART B: HOUSING LOAN CALCULATOR In this part of the assignment, you are expected to develop a program that calculates housing loan pay-...

    MATLAB!!! CAN SOMEONE SOLVE THIS PROBLEM ON MATLAB?? THANK YOU PART B: HOUSING LOAN CALCULATOR In this part of the assignment, you are expected to develop a program that calculates housing loan pay- ments based on compound interest formulas The program should prompt a user to input the amount borrowed (principal), p, the number of monthly payments, n, and an annual interest rate in R percent. The program should convert the annual interest rate R into a monthly interest rate...

  • 6) a) A mortgage (loan for buying a house) is an ordinary annuity. With a standard...

    6) a) A mortgage (loan for buying a house) is an ordinary annuity. With a standard 30-year fixed rate loan, the money is borrowed today and paid back monthly for 30 years in a constant amount. In Yolo County the maximum conforming loan amount is $552,000. A conforming loan meets conditions set by government sponsored entities (GSE) called Fannie Mae and Freddie Mac in the US. Conforming loans usually get a lower interest rate because the bank can sell them...

  • CIS 221 Loan Calculator Enhancement Introduction You are a systems analyst working for a company that...

    CIS 221 Loan Calculator Enhancement Introduction You are a systems analyst working for a company that provides loans to customers. Your manager has asked you to enhance and correct their existing Loan Calculator program, which is designed to calculate monthly and total payments given the loan amount, the annual interest rate, and the duration of the loan. Although the current version of the program (hereby termed the “As Is” version) has some functionality, there are several missing pieces, and the...

  • plz help LESSON 84 The Monthly Payment Most mortgage loans are repaid in equal payments. Each...

    plz help LESSON 84 The Monthly Payment Most mortgage loans are repaid in equal payments. Each payment includes an amount for payment of interest and an amount for payment of the principal of the loan. The amount of interest is calculated using the simple interest formula. Each payment you make decreases the amount of the principal you owe. PRINCIPAL PAYMENT - MONTHLY PAYMENT - INTEREST PAYMENT NEW PRINCIPAL - PREVIOUS PRINCIPAL PRINCIPAL PAYMENT Complete the table below. Mortgage Amount Interest...

  • Which ONE of the following is NOT a common characteristic of a Mortgage Note Payable? The...

    Which ONE of the following is NOT a common characteristic of a Mortgage Note Payable? The amount borrowed under a mortgage loan is related to the purchase of a specific asset. O Monthly payments typically include monthly interest and some portion for the principal on the mortgage note payable. The interest rate includes a 1.45% annual government charge which is paid by both the borrower and the mortgage lender. Assets purchased with a mortgage are usually pledged as security or...

  • 6) A mortgage (loan for buying a house) is an ordinary annuity. With a standard 30-year...

    6) A mortgage (loan for buying a house) is an ordinary annuity. With a standard 30-year fixed rate loan, the money is borrowed today and paid back monthly for 30 years in a constant amount. In Yolo County the maximum conforming loan amount is $552,000. A conforming loan meets conditions set by government sponsored entities (GSE) called Fannie Mae and Freddie Mac in the US. Conforming loans usually get a lower interest rate because the bank can sell them easily...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT