Saturday, January 31, 2009

Code for triangle numbers and their factors!!!

Module Module1
Sub Main()
Dim counter As Integer
'add another variable!
Dim diff As Integer = 1
Dim totalFactors As Integer = 0
Dim factorCounter As Integer
For counter = 1 To 60000
'Console.WriteLine(counter)
For factorCounter = 1 To counter
If counter Mod factorCounter = 0 Then
totalFactors = totalFactors + 1
End If
Next
If totalFactors > 50 Then
Console.WriteLine(counter)
End If
counter = counter + diff
diff = diff + 1
totalFactors = 0
Next

'1, 3, 6, 10, 15, 21, 28
'print out the first 10 triangle numbers!
Console.ReadLine()
End Sub
End Module

On your blog...

Please explain...

  • What an if statement is and what it is used for.
  • What a loop is and what it is used for.

Put a code example on your blog. What is the syntax for each!

Saturday, January 24, 2009

First code in VB .NET!

Module Module1
Sub Main()
'to make a variable ... Dim variable1 As
'Console write line!
'Console read line!
'This is a comment. You use comments so other programmers
'can know what you mean!!
'Miles Per Gallon Calculator!
Dim miles As Decimal
Dim gallons As Decimal
Dim mpg As Decimal
Console.WriteLine("Please enter the distance in miles:")
miles = Console.ReadLine
Console.WriteLine("Please enter the gallons used:")
gallons = Console.ReadLine
' We need to calculate the miles per gallon!
mpg = miles / gallons
Console.WriteLine(mpg)
'Console.ReadLine()
'to see if we have the correct information
'100 miles / 10 gallons of gas -> 10 mpg
End Sub
End Module

We are going to work on a MPG program next!

It will be fun!

A great site to learn about OO Programming Using VB

Great site to learn about OO using VB!

http://www.codeproject.com/KB/vb/OOPS_In_VBNET.aspx

What are possible attributes and methods for a Lemonade Stand?

On a blog,

http://www.blogger.com/

I'd like you to list the possible attributes and methods for a Lemonade stand.

When you are finished with your blog, I'd like you to email me the URL.

You may work with someone next to you!

I'd also like you to include the data type for your attributes:

http://www.ondotnet.com/pub/a/dotnet/2001/07/30/vb7.html

DF

OO Programming!

http://mdcvb.blogspot.com/2008/09/object-oriented-programming_13.html

Key words RESERVED!!

http://mdcvb.blogspot.com/2008/09/object-oriented-programming.html

Email

  1. What's your name?
  2. What sort of programming experience do you have?
  3. What are you interested in getting out of this class?
  4. Is this class for your job or personal reasons?

david.freer@gmail.com

Welcome to class!

I look forward to a great semester!