I need help with the calculations done in a change concevter. The user enters the amount owed and the amount the purchaser paid and the change due, followed by the amount of dollars, quarters, nickles, dimes, and pennies are displayed. I have been working on this for a while and understand the subtracting the paid from the owed....the rest...im lost... A picture of my layout is displayed after my code
Thanks for the help!
Here is my code:
Public Class Form1
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
txtOwed.Text = String.Empty
txtPaid.Text = String.Empty
txtChange.Text = String.Empty
txtDollars.Text = String.Empty
txtQuarters.Text = String.Empty
txtDimes.Text = String.Empty
txtNickles.Text = String.Empty
txtPennies.Text = String.Empty
txtOwed.Focus()
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim decOwed As Decimal
Dim decPaid As Decimal
Dim decChange As Decimal
Dim intDollars As Integer
Dim intQuarters As Integer
Dim intDimes As Integer
Dim intNickels As Integer
Dim intPennies As Integer
Const dollars = 1
Const quarters = 25
Const dimes = 10
Const nickels = 5
Const pennies = 100
'Variables
decChange = decOwed - decPaid
txtChange.Text = decChange
intDollars = Val(txtDollars.Text)
intQuarters = Val(txtQuarters.Text)
intDimes = Val(txtDimes.Text)
intNickels = Val(txtNickles.Text)
intPennies = Val(txtPennies.Text)
decChange = Val(txtChange.Text)
'Dollars
intDollars = intPennies / 100
txtDollars.Text = intDollars.ToString
'Quarters
intQuarters = intPennies / 25
txtQuarters.Text = intQuarters.ToString
'Dimes
intDimes = intPennies / 10
txtDimes.Text = intDimes.ToString
'Nickels
intNickels = intPennies / 5
txtNickles.Text = intNickels.ToString
'Pennies
intDollars = intPennies / 1
txtPennies.Text = intPennies.ToString
End Sub
Private Sub txtOwed_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtOwed.KeyPress
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso
e.KeyChar <> ControlChars.Back AndAlso
e.KeyChar <> "$" AndAlso
e.KeyChar <> "." Then
e.Handled = True
End If
End Sub
End Class