Inevdt's Profile
Reputation: 2
Apprentice
- Group:
- New Members
- Active Posts:
- 12 (0.03 per day)
- Joined:
- 29-February 12
- Profile Views:
- 470
- Last Active:
Apr 22 2012 07:27 PM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: StackOverflowException was unhandled; ASP.NET
Posted 21 Apr 2012
Thanks so much. Such a little mistake that can ruin the whole program lol. -
In Topic: VB.NET System.StackOverflowExeption Error
Posted 29 Mar 2012
Hahaha Thanks so much. I just replacedReturn MonthlyPayment()
With
Return MonthlyPayment
Seems to have fixed the probably for me. It always amazes me how just the slightest typo can kill your code. Thanks for pointing that out, I probably would have kept overlooking it for a while. -
In Topic: VB.NET System.StackOverflowExeption Error
Posted 29 Mar 2012
It actually times out after the StackOverFlow exeption occurs and the program ceases to function. I get the (not responding) message on the window title. I'm in a group project for this and my fellow classmates have a similar build as mine and their code executes without any problem so I have no idea what is going on with mine. -
In Topic: Code gives out NaN as result
Posted 1 Mar 2012
Alright thanks, I'll probably end up turning this into a program with a GUI in the future so the results will just display in a dialog box that should hold all the lines. -
In Topic: Code gives out NaN as result
Posted 1 Mar 2012
Ok, so I've updated my code to show the payment schedule for however long the user inputs for the term length. The calculation looks a little confusing but it gets the job done correctly. The only problem I'm having is that when the results are displayed to the console, if the results are too long, the console cuts off part of the results. For example, if I inputted a loan amount of 5000 at a rate of %5 for 30 years, it will show the results of each year for a few seconds and move on till the next until year 30 each reach. But when I try to scroll back up to the beginning, it is cut off. Is there a fix to this or is it the nature of the console display to only hold a certain amount of lines? Thanks for the help
'Mortgage Calculator Change Request #12 'Joseph M Pimentel 'University of Phoenix 'POS/408 'March 5, 2012 ' The following code was created for McBride Financial Services to use to amoritize loans. ' This console code will calculate and display the monthly payment amount to fully amortize a loan. ' This console code will prompt the user to input values for the loan amount, the term length, and the rate. ' This console code will take user input and create a table listing each monthly payment over the entire length of the loan. Module Module1 'Declares strings used for user input values Dim Principle As Double Dim Term As Double Dim Interest As Double Dim iPrinciple As String Dim iTerm As String Dim iInterest As String Dim FinPayment As Double Sub Main() Console.WriteLine("Welcom to Joseph's Mortgage Calculator") 'States Programs Name Console.WriteLine("Developed by: Joseph M. Pimentel") 'States developers Name Dim PrincipleInput As Boolean = False ' Input stays false unless proven true Do While PrincipleInput = False Console.WriteLine(ControlChars.NewLine & "Please enter loan amount: ") 'Prompts user for loan amount iPrinciple = Console.ReadLine() 'Read users input Try Principle = CDbl(iPrinciple) 'Converts user input value to a double PrincipleInput = True 'Input is valid, continue Catch Console.WriteLine(ControlChars.NewLine & "Loan amount entered was invalid." & ControlChars.NewLine & "Enter loan amount numerically without the $ sign such as 200000 or 200,000.") End Try Loop Dim InterestInput As Boolean = False 'Input stays false unless proven true Do While InterestInput = False Console.WriteLine(ControlChars.NewLine & "Please enter interest rate: ") 'Prompts user for interest rate iInterest = Console.ReadLine() 'Read users input Try Interest = CDbl(iInterest) 'Converts user input value to a double InterestInput = True 'Input is valid, continue Catch Console.WriteLine(ControlChars.NewLine & "Interest amount entered was invalid." & ControlChars.NewLine & "Enter Interest amount numerically without the % sign such as 5 or 5.75.") End Try Loop Dim TermInput As Boolean = False 'Input stays false unless proven true Do While TermInput = False Console.WriteLine(ControlChars.NewLine & "Please enter term length in years: ") 'Prompts user for term length iTerm = Console.ReadLine() 'stores term length Try Term = CDbl(iTerm) 'Converts user input value to a double TermInput = True 'Input is valid, continue Catch Console.WriteLine(ControlChars.NewLine & "Term length entered was invalid." & ControlChars.NewLine & "Enter term length numberically such as 15 or 30.") End Try Loop FinPayment = MonthlyPayment() Console.WriteLine(ControlChars.NewLine & "The monthly payment for a loan of $" & Principle & " at a rate of %" & Interest & ControlChars.NewLine & " for " & Term & " years" & " is " & FinPayment.ToString("C")) 'Shows monthly payment Table() Console.WriteLine(ControlChars.NewLine & "Please press ENTER to exit") Console.ReadLine() End Sub Private Function MonthlyPayment() 'IntFormat converts the Interest Rate into the monthly interest in decimal form 'TermFormat converts the Term length of years into months 'Power and Final are created to be used in the monthly payment Dim IntFormat As Double = Interest / (12 * 100) Dim TermFormat As Double = (Term * 12) Dim Power As Double = (1 + IntFormat) Dim Final As Double = Math.Pow(Power, -TermFormat) Final = (1 - Final) 'Calculates the final value Final = (1 / Final) 'Inverts the final value so that it is mulitplied correctly within the following equation 'The following two lines calculate the Monthly payment. MonthlyPayment = Principle * (IntFormat / 1 - (Math.Pow(Power, -TermFormat))) MonthlyPayment = (Final * Principle * IntFormat) Return MonthlyPayment End Function Private Sub Table() 'For use in the loop Dim Year As Double = 0 Dim MInterest As Double 'Monthly Interest value Dim Int As Double 'Standard interest value Dim Princ As Double 'Standard Loan value Dim MPrinc As Double 'Current Loan value Dim iYear As Double 'For use as the loop print out Dim Balance As Double 'Holds value for the current loan balance Dim Output As String 'Used for printout Dim PaymentNum As Double 'Used to count payment number Dim iPaymentNum As Double 'Used for the loop print out Int = Interest / (12 * 100) 'Sets the interest rate 'Sets loan amount Princ = Principle Balance = Princ 'Line break Console.WriteLine(ControlChars.NewLine) Do While Year < Term 'Year loop iYear = (Year + 1) PaymentNum = 0 'Resets payment for the year Do While PaymentNum < 12 'Payment Number loop iPaymentNum = (PaymentNum + 1) MInterest = (Princ * Int) 'Calculates monthly interest MPrinc = (FinPayment - MInterest) 'Calculates the monthly principal amount Princ = (Princ - MPrinc) 'Subtracts the principal from the loan amount that has already been paid for the month If Balance > 0 Then Output = "Payment " & iPaymentNum.ToString & " Year " & iYear.ToString & ": Principal= " & MPrinc.ToString("C") & " Interest= " & MInterest.ToString("C") & " Balance= " & Princ.ToString("C") Console.WriteLine(Output) Balance = Princ 'Saves the current balance for next calculation PaymentNum += 1 'Add to the payment number to keep in sync Else PaymentNum = 12 Year = Term End If Loop 'Line Break between years Console.WriteLine(ControlChars.NewLine) 'Pause between years System.Threading.Thread.Sleep(3000) Year += 1 'Add to the Year number to keep in sync Loop End Sub End Module
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Private
Friends
Inevdt hasn't added any friends yet.
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
Inevdt has no profile comments yet. Why not say hello?