Make Change Machine
Make Change Machine
Make Change Machine
Make Change Machine
Make Change Machine
Make Change Machine Make Change Machine Make Change Machine Make Change Machine Make Change Machine Make Change Machine Make Change Machine Make Change Machine
Make Change Machine Make Change Machine
Make Change Machine
Go Back  Xtreme Visual Basic Talk > > > Make Change Machine


Reply
 
Thread Tools Display Modes
  #1  
Old 12-11-2015, 11:29 PM
VB_Confuse VB_Confuse is offline
Newcomer
 
Join Date: Dec 2015
Posts: 1
Default Make Change Machine


i need help in making a change machine this is what i got so far
Code:
 Dim Quarter, Dime, Nickel, Penny As Decimal
    Dim Cost As Decimal
    Dim Cash As Decimal
    Dim Change As Decimal



    Private Sub ChangeButton_Click(sender As Object, e As EventArgs) Handles ChangeButton.Click
        Dim converted As Boolean = Decimal.TryParse(CostTextBox.Text, Cost)
        Cash = CDec(CashTextBox.Text)
        ChangeLabel.Text = CStr(Cash - Cost)

        Quarter = CDec(Int(Change / 0.25))
        Dim RemainingChange As Decimal = CDec(Change - (Quarter * 0.25))
        Dim s As String = String.Format("0.25", Quarter)
        If (Change / Quarter) >= 0 Then
            Quarter = CDec(Change / 0.25)
            Change = CDec((Quarter * 0.25) - Change)
        End If

        ChangeTextBox.Text &= "Quarter:" & Quarter & vbCrLf

        Dime = CDec(Int(Change / 0.1))
        RemainingChange = CDec(Change - (Dime * 0.1))
        s = String.Format("0.1", Dime)
        ChangeTextBox.Text &= "Dime:" & Dime & vbCrLf

        Nickel = CDec(Int(Change / 0.05))
        RemainingChange = CDec(Change - (Nickel * 0.05))
        s = String.Format("0.05", Nickel)
        ChangeTextBox.Text &= "Nickel:" & Nickel & vbCrLf

        Penny = CDec(Int(Change / 0.01))
        RemainingChange = CDec(Change - (Penny * 0.01))
        s = String.Format("0.01", Penny)
        ChangeTextBox.Text &= "Penny:" & Penny & vbCrLf
Reply With Quote
  #2  
Old 12-12-2015, 09:08 AM
dbasnett's Avatar
dbasnett dbasnett is offline
Junior Contributor
 
Join Date: May 2005
Posts: 299
Default

Someone with the same user name posted the same question at DreamInCode. They received five pages of responses.
Reply With Quote
  #3  
Old 12-12-2015, 01:37 PM
Cerian Knight's Avatar
Cerian KnightMake Change Machine Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,199
Default

Actually, 7 now. I read the progression over at D.I.C., so the code above is a good start.

@VB_Confuse: As you already understand, we won't do this for you, but we will provide help commensurate with your effort. So, pick some aspect of this that is still causing a problem. For example, tell us what the code does not do that you want it to do (with examples of the output as written and expected output). Or, show us what lines or statements in the code you don't understand and need more explanation on.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #4  
Old 12-12-2015, 02:02 PM
Cerian Knight's Avatar
Cerian KnightMake Change Machine Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,199
Default

To reiterate what someone else had mentioned, it is usually best to tell the computer what you know up front, which makes the logic flow more easily from there:
Code:
Const Quarter As Decimal = 0.25, Dime As Decimal = 0.1, Nickel As Decimal = 0.05, Penny As Decimal = 0.01
You may have to change (simplify) some of your existing logic to make this work (better) for you.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #5  
Old 12-21-2015, 07:09 AM
Goggy's Avatar
Goggy Goggy is offline
Contributor
 
Join Date: Sep 2005
Location: Enschede,The Netherlands
Posts: 670
Default I think this post could help you out

__________________
As finishing touch, god created the Dutch!

utterly useless, but always trying to help
Reply With Quote
Reply

Tags
quarter, dim, dime, penny, nickel, change, decimal, cdecchange, remainingchange, changetextbox.text, vbcrlf, cdecintchange, cost, cash, machine, cstrcash, cdecquarter, string.format0.05, string.format0.25, string.format0.1, changelabel.text, string.format0.01, string, handles, private


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Make Change Machine
Make Change Machine
Make Change Machine Make Change Machine
Make Change Machine
Make Change Machine
Make Change Machine Make Change Machine Make Change Machine Make Change Machine Make Change Machine Make Change Machine Make Change Machine
Make Change Machine
Make Change Machine
 
Make Change Machine
Make Change Machine
 
-->