This program you are supposed to enter the amount owed the amount of money paid and get the change due. then take the change and tell the used how many dollars, quarters, dimes, nickels, and pennies due in change. i can not figure out where my calculations went wrong. Does anyone have any ideas?????
here is the code as i programmed it.
Public Class ChangeForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TitleLabel As System.Windows.Forms.Label
Friend WithEvents AmountOwedLabel As System.Windows.Forms.Label
Friend WithEvents ChangeDueLabel As System.Windows.Forms.Label
Friend WithEvents AmountOwedTextBox As System.Windows.Forms.TextBox
Friend WithEvents ChangeDueTextBox As System.Windows.Forms.TextBox
Friend WithEvents DollarsIdLabel As System.Windows.Forms.Label
Friend WithEvents QuartersIdLabel As System.Windows.Forms.Label
Friend WithEvents DimesIdLabel As System.Windows.Forms.Label
Friend WithEvents NickelIdLabel As System.Windows.Forms.Label
Friend WithEvents PenniesIdLabel As System.Windows.Forms.Label
Friend WithEvents QuarterTextLabel As System.Windows.Forms.Label
Friend WithEvents DimesTextLabel As System.Windows.Forms.Label
Friend WithEvents NickelTextLabel As System.Windows.Forms.Label
Friend WithEvents PenniesTextLabel As System.Windows.Forms.Label
Friend WithEvents ExitButton As System.Windows.Forms.Button
Friend WithEvents calculateButton As System.Windows.Forms.Button
Friend WithEvents ClearButton As System.Windows.Forms.Button
Friend WithEvents DollarTextLabel As System.Windows.Forms.Label
Friend WithEvents AmountPaidLabel As System.Windows.Forms.Label
Friend WithEvents AmountPaidTextBox As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TitleLabel = New System.Windows.Forms.Label
Me.AmountOwedLabel = New System.Windows.Forms.Label
Me.ChangeDueLabel = New System.Windows.Forms.Label
Me.AmountOwedTextBox = New System.Windows.Forms.TextBox
Me.ChangeDueTextBox = New System.Windows.Forms.TextBox
Me.DollarsIdLabel = New System.Windows.Forms.Label
Me.QuartersIdLabel = New System.Windows.Forms.Label
Me.DimesIdLabel = New System.Windows.Forms.Label
Me.NickelIdLabel = New System.Windows.Forms.Label
Me.PenniesIdLabel = New System.Windows.Forms.Label
Me.DollarTextLabel = New System.Windows.Forms.Label
Me.QuarterTextLabel = New System.Windows.Forms.Label
Me.DimesTextLabel = New System.Windows.Forms.Label
Me.NickelTextLabel = New System.Windows.Forms.Label
Me.PenniesTextLabel = New System.Windows.Forms.Label
Me.ExitButton = New System.Windows.Forms.Button
Me.calculateButton = New System.Windows.Forms.Button
Me.ClearButton = New System.Windows.Forms.Button
Me.AmountPaidLabel = New System.Windows.Forms.Label
Me.AmountPaidTextBox = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'TitleLabel
'
Me.TitleLabel.AutoSize = True
Me.TitleLabel.Location = New System.Drawing.Point(184, 8)
Me.TitleLabel.Name = "TitleLabel"
Me.TitleLabel.Size = New System.Drawing.Size(57, 21)
Me.TitleLabel.TabIndex = 0
Me.TitleLabel.Text = "Change"
'
'AmountOwedLabel
'
Me.AmountOwedLabel.AutoSize = True
Me.AmountOwedLabel.Location = New System.Drawing.Point(16, 40)
Me.AmountOwedLabel.Name = "AmountOwedLabel"
Me.AmountOwedLabel.Size = New System.Drawing.Size(109, 21)
Me.AmountOwedLabel.TabIndex = 1
Me.AmountOwedLabel.Text = "Amount Owed:"
'
'ChangeDueLabel
'
Me.ChangeDueLabel.AutoSize = True
Me.ChangeDueLabel.Location = New System.Drawing.Point(16, 112)
Me.ChangeDueLabel.Name = "ChangeDueLabel"
Me.ChangeDueLabel.Size = New System.Drawing.Size(93, 21)
Me.ChangeDueLabel.TabIndex = 3
Me.ChangeDueLabel.Text = "C&hange Due:"
'
'AmountOwedTextBox
'
Me.AmountOwedTextBox.Location = New System.Drawing.Point(128, 40)
Me.AmountOwedTextBox.Name = "AmountOwedTextBox"
Me.AmountOwedTextBox.Size = New System.Drawing.Size(72, 25)
Me.AmountOwedTextBox.TabIndex = 2
Me.AmountOwedTextBox.Text = ""
'
'ChangeDueTextBox
'
Me.ChangeDueTextBox.Location = New System.Drawing.Point(128, 112)
Me.ChangeDueTextBox.Name = "ChangeDueTextBox"
Me.ChangeDueTextBox.Size = New System.Drawing.Size(72, 25)
Me.ChangeDueTextBox.TabIndex = 4
Me.ChangeDueTextBox.Text = ""
'
'DollarsIdLabel
'
Me.DollarsIdLabel.AutoSize = True
Me.DollarsIdLabel.Location = New System.Drawing.Point(224, 48)
Me.DollarsIdLabel.Name = "DollarsIdLabel"
Me.DollarsIdLabel.Size = New System.Drawing.Size(60, 21)
Me.DollarsIdLabel.TabIndex = 7
Me.DollarsIdLabel.Text = "&Dollars:"
'
'QuartersIdLabel
'
Me.QuartersIdLabel.AutoSize = True
Me.QuartersIdLabel.Location = New System.Drawing.Point(224, 80)
Me.QuartersIdLabel.Name = "QuartersIdLabel"
Me.QuartersIdLabel.Size = New System.Drawing.Size(71, 21)
Me.QuartersIdLabel.TabIndex = 9
Me.QuartersIdLabel.Text = "&Quarters:"
'
'DimesIdLabel
'
Me.DimesIdLabel.AutoSize = True
Me.DimesIdLabel.Location = New System.Drawing.Point(224, 112)
Me.DimesIdLabel.Name = "DimesIdLabel"
Me.DimesIdLabel.Size = New System.Drawing.Size(54, 21)
Me.DimesIdLabel.TabIndex = 11
Me.DimesIdLabel.Text = "D&imes:"
'
'NickelIdLabel
'
Me.NickelIdLabel.AutoSize = True
Me.NickelIdLabel.Location = New System.Drawing.Point(224, 144)
Me.NickelIdLabel.Name = "NickelIdLabel"
Me.NickelIdLabel.Size = New System.Drawing.Size(61, 21)
Me.NickelIdLabel.TabIndex = 14
Me.NickelIdLabel.Text = "&Nickels:"
'
'PenniesIdLabel
'
Me.PenniesIdLabel.AutoSize = True
Me.PenniesIdLabel.Location = New System.Drawing.Point(224, 176)
Me.PenniesIdLabel.Name = "PenniesIdLabel"
Me.PenniesIdLabel.Size = New System.Drawing.Size(64, 21)
Me.PenniesIdLabel.TabIndex = 16
Me.PenniesIdLabel.Text = "&Pennies:"
'
'DollarTextLabel
'
Me.DollarTextLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.DollarTextLabel.Location = New System.Drawing.Point(304, 48)
Me.DollarTextLabel.Name = "DollarTextLabel"
Me.DollarTextLabel.Size = New System.Drawing.Size(48, 23)
Me.DollarTextLabel.TabIndex = 8
'
'QuarterTextLabel
'
Me.QuarterTextLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.QuarterTextLabel.Location = New System.Drawing.Point(304, 80)
Me.QuarterTextLabel.Name = "QuarterTextLabel"
Me.QuarterTextLabel.Size = New System.Drawing.Size(48, 23)
Me.QuarterTextLabel.TabIndex = 10
'
'DimesTextLabel
'
Me.DimesTextLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.DimesTextLabel.Location = New System.Drawing.Point(304, 112)
Me.DimesTextLabel.Name = "DimesTextLabel"
Me.DimesTextLabel.Size = New System.Drawing.Size(48, 23)
Me.DimesTextLabel.TabIndex = 12
'
'NickelTextLabel
'
Me.NickelTextLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.NickelTextLabel.Location = New System.Drawing.Point(304, 144)
Me.NickelTextLabel.Name = "NickelTextLabel"
Me.NickelTextLabel.Size = New System.Drawing.Size(48, 23)
Me.NickelTextLabel.TabIndex = 15
'
'PenniesTextLabel
'
Me.PenniesTextLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.PenniesTextLabel.Location = New System.Drawing.Point(304, 176)
Me.PenniesTextLabel.Name = "PenniesTextLabel"
Me.PenniesTextLabel.Size = New System.Drawing.Size(48, 23)
Me.PenniesTextLabel.TabIndex = 17
'
'ExitButton
'
Me.ExitButton.Location = New System.Drawing.Point(344, 224)
Me.ExitButton.Name = "ExitButton"
Me.ExitButton.Size = New System.Drawing.Size(88, 32)
Me.ExitButton.TabIndex = 6
Me.ExitButton.Text = "E&xit"
'
'calculateButton
'
Me.calculateButton.Location = New System.Drawing.Point(24, 224)
Me.calculateButton.Name = "calculateButton"
Me.calculateButton.Size = New System.Drawing.Size(88, 32)
Me.calculateButton.TabIndex = 4
Me.calculateButton.Text = "Calculate"
'
'ClearButton
'
Me.ClearButton.Location = New System.Drawing.Point(188, 224)
Me.ClearButton.Name = "ClearButton"
Me.ClearButton.Size = New System.Drawing.Size(88, 32)
Me.ClearButton.TabIndex = 5
Me.ClearButton.Text = "C&lear"
'
'AmountPaidLabel
'
Me.AmountPaidLabel.AutoSize = True
Me.AmountPaidLabel.Location = New System.Drawing.Point(16, 76)
Me.AmountPaidLabel.Name = "AmountPaidLabel"
Me.AmountPaidLabel.TabIndex = 18
Me.AmountPaidLabel.Text = "Amount Paid:"
'
'AmountPaidTextBox
'
Me.AmountPaidTextBox.Location = New System.Drawing.Point(128, 76)
Me.AmountPaidTextBox.Name = "AmountPaidTextBox"
Me.AmountPaidTextBox.Size = New System.Drawing.Size(72, 25)
Me.AmountPaidTextBox.TabIndex = 19
Me.AmountPaidTextBox.Text = ""
'
'ChangeForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(7, 18)
Me.ClientSize = New System.Drawing.Size(456, 266)
Me.ControlBox = False
Me.Controls.Add(Me.AmountPaidTextBox)
Me.Controls.Add(Me.AmountPaidLabel)
Me.Controls.Add(Me.ClearButton)
Me.Controls.Add(Me.calculateButton)
Me.Controls.Add(Me.ExitButton)
Me.Controls.Add(Me.PenniesTextLabel)
Me.Controls.Add(Me.NickelTextLabel)
Me.Controls.Add(Me.DimesTextLabel)
Me.Controls.Add(Me.QuarterTextLabel)
Me.Controls.Add(Me.DollarTextLabel)
Me.Controls.Add(Me.PenniesIdLabel)
Me.Controls.Add(Me.NickelIdLabel)
Me.Controls.Add(Me.DimesIdLabel)
Me.Controls.Add(Me.QuartersIdLabel)
Me.Controls.Add(Me.DollarsIdLabel)
Me.Controls.Add(Me.ChangeDueTextBox)
Me.Controls.Add(Me.AmountOwedTextBox)
Me.Controls.Add(Me.ChangeDueLabel)
Me.Controls.Add(Me.AmountOwedLabel)
Me.Controls.Add(Me.TitleLabel)
Me.Font = New System.Drawing.Font("Georgia", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Name = "ChangeForm"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub TitleLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TitleLabel.Click
End Sub
Private Sub DimesTextLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DimesTextLabel.Click
End Sub
Private Sub ChangeForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub PenniesTextLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PenniesTextLabel.Click
End Sub
Private Sub QuarterTextLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuarterTextLabel.Click
End Sub
Private Sub LabelDollarText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DollarTextLabel.Click
End Sub
Private Sub NickelTextLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NickelTextLabel.Click
End Sub
Private Sub ChangeDueLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeDueLabel.Click
End Sub
Private Sub DollarsIdLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DollarsIdLabel.Click
End Sub
Private Sub ExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
Private Sub calculateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles calculateButton.Click
Dim intOwed, intPaid, intDue, intD, intQ, intI, intN, intP As Integer
intOwed = Val(Me.AmountOwedTextBox.Text)
intDue = Val(Me.ChangeDueTextBox.Text)
intD = Val(Me.DollarTextLabel.Text)
intQ = Val(Me.QuarterTextLabel.Text)
intI = Val(Me.DimesTextLabel.Text)
intN = Val(Me.NickelTextLabel.Text)
intP = Val(Me.PenniesTextLabel.Text)
intPaid = Val(Me.AmountPaidTextBox.Text)
intDue = intOwed - intPaid
intD = intDue / 100
intQ = intDue / 25
intI = intDue / 10
intN = intDue / 5
intP = intDue / 1
Me.AmountOwedTextBox.Text = intOwed
Me.AmountPaidTextBox.Text = intPaid
Me.ChangeDueTextBox.Text = intDue
Me.DollarTextLabel.Text = intD
Me.QuarterTextLabel.Text = intQ
Me.DimesTextLabel.Text = intI
Me.NickelTextLabel.Text = intN
Me.PenniesTextLabel.Text = intP
Me.PenniesTextLabel.Text = Format(Me.PenniesTextLabel.Text, "currency")
Me.QuarterTextLabel.Text = Format(Me.QuarterTextLabel.Text, "currency")
Me.DimesTextLabel.Text = Format(Me.DimesTextLabel.Text, "currency")
Me.DollarTextLabel.Text = Format(Me.DollarTextLabel.Text, "currency")
Me.NickelTextLabel.Text = Format(Me.NickelTextLabel.Text, "currency")
Me.AmountPaidTextBox.Text = Format(Me.AmountPaidTextBox.Text, "currency")
Me.AmountOwedTextBox.Text = Format(Me.AmountOwedTextBox.Text, "currency")
Me.ChangeDueTextBox.Text = Format(Me.ChangeDueTextBox.Text, "currency")
End Sub
Private Sub ClearButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ClearButton.Click
Me.AmountOwedTextBox.Text = ""
Me.AmountPaidTextBox.Text = ""
Me.ChangeDueTextBox.Text = ""
Me.DollarTextLabel.Text = ""
Me.DimesTextLabel.Text = ""
Me.QuarterTextLabel.Text = ""
Me.NickelTextLabel.Text = ""
Me.PenniesTextLabel.Text = ""
Me.AmountOwedTextBox.Focus()
End Sub
End Class