Yes, it IS homework. No, please don't do it for me because I need to learn it, and I don't want to be kicked out!
I'm working on a mortgage calc program. It must display output (to a DOS window) of a $200k loan with 3 different interest rates, AND print out the monthly payments. The figures are - - 7 years at 5.35% - 15 years at 5.5%
- 30 years at 5.75%.
I have done it before in another class (it was a Java console application) and now I'm just trying to port it to VB.Net.
Here is my code so far. It barfs on my looping so far -
Module Module1
Sub Main()
System.Console.WriteLine()
System.Console.WriteLine("Welcome to Jim's Mortgage Calculator")
System.Console.WriteLine()
System.Console.WriteLine("A $200,000 Home Loan given three different loan terms and interest rates.")
System.Console.WriteLine("This calculator will determine the monthly payment for each loan and print out the payment schedule.")
System.Console.WriteLine()
'Program Variables using array
Dim principleAmountTerms() As Double = {84, 180, 360} 'monthly loan rates given
Dim aInterest() As Double = {0.0535, 0.055, 0.0575} 'APR given for each loan
Dim principleAmount As Double 'principle variable
Dim monthTerm, monthlyInterest As Double 'monthly terms and interest variables
Dim x As Integer = 0
'for loop assigning start point for the displaying of each loan followed by the next
for (principleAmount = 200000 or x= 0 or x < principleAmountTerms (x)++)
'construct math to calculate monthly payment in the for loop
monthlyInterest = aInterest(x)
monthTerm = principleAmountTerms(x)
Dim monthlyRate As Double = (monthlyInterest / 12)
Dim monthlyDifference As Double = (Math.Pow((1 + monthlyRate), monthTerm) - 1) / (monthlyRate * Math.Pow((1 + monthlyRate), monthTerm)) 'account for monthly interest rates over APR figures
Dim startProcess As Double = principleAmount / monthlyDifference 'calculate payable amount per month
'constructing output for individual loans prior to the scrolling rates
System.Console.WriteLine("Current loan balance is: " & (principleAmount) + " ")
System.Console.WriteLine("Current loan interest rate: " & monthlyInterest * 100 + "%" + " ")
System.Console.WriteLine("The monthly term of the loan is: " & monthTerm + " months.")
Next
Dim loanLooper As String
Dim currentLoan As Double
Dim MonthlyInterestRate As Double
Dim LoanAmount As Double
Dim MonthlyPayment As Double
System.Console.WriteLine()
System.Console.WriteLine("Month " & " " + "Loan Amount" & " " + "Interest " & " " & "Loan Balance ")
System.Console.WriteLine("----- " & " " + "-----------" & " " + "-------- " & " t" & "------------ ")
Dim eachLoan As Integer = 1
Dim loanBalance As Double = 0, Interest
While (eachLoan <= currentLoan)
End While
Int(x = 0)
'display is 15 lines long
While (x < 15 & loanBalance >= 0)
End While
loanBalance = LoanAmount * (1 + MonthlyInterestRate) - MonthlyPayment 'Math for loan balance
Interest = LoanAmount * MonthlyInterestRate 'math for interest rate
System.Console.WriteLine("" + eachLoan + " " + (Math.Round(LoanAmount * 1000.0) / 100.0) + " " + (Math.Round(Interest * 1000.0) / 100.0) + " " + (Math.Round(loanBalance * 1000.0) / 100.0))
LoanAmount = loanBalance
' eachLoan++
'(x)++
System.Console.WriteLine("Press the Enter key to continue...")
'BufferedReader(enter = New BufferedReader(New InputStreamReader(System.in), 1))
'BufferedReader(enter = New IO.BufferedStream(New IO.StreamReader(System.In), 1))
' String str = ""
'Try
'Str = enter.readLine() 'Use loops to prevent lists from scrolling off the screen
'catch (IOException ioe) System.Console.WriteLine(ioe)
'End Try
End Sub
End Module
Thanks in advance for any help/hints, or just a slap upside the head!
- Jim

New Topic/Question
Reply



MultiQuote





|