I am in the process of learning VBNET i am working on a program that wants me to use an input box so the user can insert an amount of pennies. ideally the projram is supposed to come up with the result on how many dollars, quarters, dimes,nickels, and pennies the user wouldget for cashing in thire pennies. My problem is im not sure what math procedure i sould use and how to word it. can someone give me some ideas???
You don't need any math procedure (assuming you mean a library function) as this task involves no more than is simple arithmetic:
Do While pennies >= 5 If pennies >= 100 Then dollars += 1 pennies -= 100 Else If pennies >= 25 Then quarters += 1 pennies -= 25 Else If pennies >= 10 Then dimes += 1 pennies -= 10 Else If pennies >= 5 Then nickels += 1 pennies -= 5 End If Loop
will that make it do 2448 pennies is so many dollars,so many quarters, so many dimes , so many nickels, so many [pennies. sort of like what the coin star machins will do..? But this exercise is not supposed to use loops but thanks for the suggestion.
this is what happened when i tried the loop you suggested :
i entered the amount of pennies as 9559
the out put was 69 dollars, 2.00 in quarters, no dimes 1.00 in nickels and no pennies. i do not belive this is correct. here is the code maybe i typed it wrong:
Private Sub CalculateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CalculateButton.Click Dim intB, IntQ, intD, intN, intP As Integer Do While mstrPennies >= 5 If mstrPennies >= 100 Then intB += 1 mstrPennies -= 100 ElseIf mstrPennies >= 25 Then IntQ += 1 mstrPennies -= 25 ElseIf mstrPennies >= 10 Then intD += 1 mstrPennies -= 10 ElseIf mstrPennies >= 5 Then intN += 1 mstrPennies -= 5 ElseIf mstrPennies >= 1 Then intP += 1 mstrPennies -= 1 End If Loop Me.DollarTextLabel.Text = intB Me.QuarterTextLabel.Text = IntQ Me.DimesTextLabel.Text = intD Me.NickelTextLabel.Text = intN Me.PenniesTextLabel.Text = intP Me.DollarTextLabel.Text = Format(Me.DollarTextLabel.Text, "currency") Me.QuarterTextLabel.Text = Format(Me.QuarterTextLabel.Text, "currency") Me.DimesTextLabel.Text = Format(Me.DimesTextLabel.Text, "currency") Me.NickelTextLabel.Text = Format(Me.NickelTextLabel.Text, "currency") Me.PenniesTextLabel.Text = Format(Me.PenniesTextLabel.Text, "currency")
does anyone else have any ideas.