Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 132,120 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,005 people online right now. Registration is fast and FREE... Join Now!




pennies calculator

 
Reply to this topicStart new topic

pennies calculator

sshulawsr1
post 22 Nov, 2007 - 10:23 PM
Post #1


New D.I.C Head

*
Joined: 22 Nov, 2007
Posts: 1


My Contributions


I have a an extra credit assignment. it is a calculator that you enter the amount of pennies & hit calculate & it has 5 dispaly labels, dollar,quarter,dimes,nickel,pennies. We have to use integer as the variables & integer division and/or mod operator & just 1 tyrparse statement. here is what I have, but does not work on all number combinations. Can anyone help?

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
'closes the form
Me.Close()
End Sub

Private Sub NumberofPenniesTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumberofPenniesTextBox.TextChanged
'Clears the number of pennies textbox when selection changed
Me.DollarsResultLabel.Text = ""
Me.QuarterResultLabel.Text = ""
Me.DimesResultLabel.Text = ""
Me.NickelsResultLabel.Text = ""
Me.PenniesResultLabel.Text = ""



End Sub

Private Sub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
Dim numberofpennies As Integer

Integer.TryParse(Me.NumberofPenniesTextBox.Text, numberofpennies)
Me.DollarsResultLabel.Text = numberofpennies \ 100
Me.QuarterResultLabel.Text = numberofpennies Mod 4
Me.DimesResultLabel.Text = numberofpennies Mod 3
Me.NickelsResultLabel.Text = numberofpennies Mod 2
Me.PenniesResultLabel.Text = numberofpennies Mod 5


End Sub
End Class
User is offlineProfile CardPM

Go to the top of the page

dedman
post 23 Nov, 2007 - 07:03 PM
Post #2


D.I.C Head

Group Icon
Joined: 22 Apr, 2005
Posts: 52


My Contributions


If you enter 347 for the number of pennies, should your program show:
Dollars = 3 Quarters = 1 Dimes = 2 Nickels= 0 Pennies = 2?
Or
Dollars = 3, Quarters = 13, Dimes = 34, Nickels = 69, Pennies = 347?
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/21/08 10:54AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month