ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 13th, 2010, 01:04 PM
WarpdPerspectiv WarpdPerspectiv is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2010
Posts: 12 WarpdPerspectiv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 30 m 45 sec
Reputation Power: 0
Need help with VB program

Basically writing a program for class and I'm not sure exactly how to make it work. I would look in the book for the answers, but it doesn't help because it doesn't give complete programs as examples, only bits and pieces of certain ones. So looking at an example in the book won't help.
The code I have so far is this:
Main code:
Code:
Module Chap10Tester

    Sub Main()
        SavingsAccount.Rate = 0.04


        Console.WriteLine("Initial interest is: " & SavingsAccount.Rate)
        Console.WriteLine()
        Dim c1 As New Customer("AAA", 4000.0)
        Dim c2 As New Customer("BBB", 5000.0)
        c1.Account.calculateMonthlyInterest()
        c2.Account.calculateMonthlyInterest()
        c1.DisplayInfo()
        c2.DisplayInfo()

        SavingsAccount.rate = 0.06

        Console.WriteLine("New interest is: " & SavingsAccount.Rate)
        Console.WriteLine()
        c1.Account.calculateMonthlyInterest()
        c2.Account.calculateMonthlyInterest()
        c1.DisplayInfo()
        c2.DisplayInfo()
    End Sub

End Module


SavingsAccount class:
Code:
Public Class SavingsAccount
    'declare instance variables here    
    Private savingsBalance As Double
    Private annualInterestRate As Double



    Public Sub New(ByVal balance As Double)
        savingsBalance = balance
    End Sub

    Public Property Balance() As Double
        Get
            Return savingsBalance
        End Get
        Set(ByVal value As Double)
            savingsBalance = value
        End Set
    End Property

    Public Shared Property Rate() As Double
        Get
            Return annualInterestRate
        End Get
        Set(ByVal value As Double)
             = value
        End Set


    End Property

    Public Function calculateMonthlyInterest() As Double
        monthlyInterest = (savingsBalance * annualInterestRate / 12) + savingsBalance

        Return monthlyInterest
        'calculate monthly interest using savingsBalance * 
        'annualInterestRate / 12, then add this monthly interest to  
        'savingsBalance,  and return the monthly interest      


    End Function

    Public Sub displayInfo()
        Console.WriteLine("Annual interest rate: " & FormatNumber(Rate, 2))
        Console.WriteLine("Account balance is: " & FormatCurrency(Balance, 2))
    End Sub
End Class


Customer class:
Code:
Public Class Customer
    'declare instance variables here    
    Private nameValue As String
    Private accountValue As String


    Public Sub New(ByVal name As String, ByVal balance As Double)
        'complete the constructor definition here    


    End Sub

    Public Property Name() As String
        Get
            Return nameValue
        End Get
        Set(ByVal value As String)
            nameValue = value
        End Set
    End Property

    Public Property Account() As SavingsAccount
        'complete the property definition here 
        Get
            Return accountValue
        End Get
        Set(ByVal value As Double)
            accountValue = value
        End Set

    End Property

    Public Sub DisplayInfo()
        Console.WriteLine("Customer Name: " & Name)
        accountValue.displayInfo()
        Console.WriteLine()
    End Sub
End Class


What the end result is supposed to look like

Okay for some reason linking or showing an image isn't working, so I'm just gonna post the URL
http://img246.imageshack.us/img246/6933/blergh.jpg

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Need help with VB program


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap