Need VB.Net help with a Console Application

Need help porting a Java console app to VB.Net console app.

Page 1 of 1

2 Replies - 3683 Views - Last Post: 26 September 2008 - 03:16 PM Rate Topic: -----

#1 jpowers5882  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 05-June 08

Need VB.Net help with a Console Application

Posted 26 September 2008 - 01:16 PM

Hi everyone,

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! :rolleyes:

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

Is This A Good Question/Topic? 0
  • +

Replies To: Need VB.Net help with a Console Application

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Need VB.Net help with a Console Application

Posted 26 September 2008 - 02:00 PM

Slaps jpowers5882 upside the head.

The problem is you have too much Java syntax and not enough VB.NET.

Perhaps you should go back to your VB.NET book and re-read the syntax of the language.

This is not a VB.NET For loop.
for (principleAmount = 200000 or x= 0 or x < principleAmountTerms   (x)++)


Was This Post Helpful? 0
  • +
  • -

#3 jacobjordan  Icon User is offline

  • class Me : Perfection
  • member icon

Reputation: 113
  • View blog
  • Posts: 1,499
  • Joined: 11-June 08

Re: Need VB.Net help with a Console Application

Posted 26 September 2008 - 03:16 PM

There's your problem. A VB.NET for loop has this syntax
Dim X As Integer
For X = Minimum To Maximum Step Increment

Next


So, to create a for loop that will start at 0 and end at 100 and skip every other number, it would look like
Dim X As Integer
For X = 0 To 100 Step 2
     'put your code here
Next


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1