473,406 Members | 2,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Calculating Coins

I'm a newbie to the programming field and I really need help to understand what i'm doing wrong. This is the exercise i'm working on I need to create an application that allows the users to enter the number of pennies in a jar. The application then calculates the number of dollars, quarters, dimes, nickles, and pennies that he will receive when he cashes in the pennies. Any guidance would be greatly appreciated.

MsBarnes

This is the codes that I have started off with:
Option Explicit On
Option Strict On

Public Class MainForm


Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
Me.Close()
End Sub

Private Sub xCalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xCalculateButton.Click
' calculate the total number of coins return


' declare variables
Dim num As Integer
Dim dollar As Integer
Dim quarter As Integer
Dim dime As Integer
Dim nickle As Integer
Dim penny As Integer

' calculate and display the amount of coins

Integer.TryParse(Me.xamountTextBox.Text, num)
Integer.TryParse(Me.xDollarTextBox.Text, dollar)
dollar = num \ 100
Integer.TryParse(Me.xQuarterTextBox.Text, quarter)
quarter = num Mod 100 \ 25
Integer.TryParse(Me.xDimeTextBox.Text, dime)
dime = num Mod 100 \ 10
Integer.TryParse(Me.xNickleTextBox.Text, nickle)
nickle = num Mod 100 \ 5
Integer.TryParse(Me.xPennyTextBox.Text, penny)
penny = num Mod 100 \ 1


End Sub

Private Sub xClearButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xClearButton.Click
' prepare the screen for the next amount

Me.xamountTextBox.Text = String.Empty
Me.xDollarTextBox.Text = String.Empty
Me.xQuarterTextBox.Text = String.Empty
Me.xDimeTextBox.Text = String.Empty
Me.xNickleTextBox.Text = String.Empty
Me.xPennyTextBox.Text = String.Empty


End Sub
End Class
Nov 11 '07 #1
1 2064
Killer42
8,435 Expert 8TB
Have you made any progress on this?

I suspect the order of precedence may have been the root of your problem. (Meaning, perhaps the division happened before the Mod.)
Nov 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any...
0
by: Kasp | last post by:
Hi there, I am trying to make an OLAP cube on a table having two columns (datetime, Number_of_times_an_event_occured). My dimension is time and I want to measure the Min and Max times an event...
1
by: Joe Bongiardina | last post by:
What does the message "calculating...." mean in the lower left status area of a form? I have a form with no calculated, concatenated or lookup fields, yet it displays this msg. The form takes...
1
by: jlm | last post by:
I have a form which feeds table (TblEmpLeave) of Employee Leave Time (time taken off for Administrative, Annual, Sick, Compensation leave). I have EmpID, LeaveDate, LeaveType, LeaveHours fields on...
0
by: robin9876 | last post by:
In an Access 2000 database on some forms 'Calculating...' is continuously displayed in the status bar window and the text of the control is automatically selected. The only workaround is switching...
5
by: sugaray | last post by:
Hi, my problem with calculating the size of an array is when I pass an array as a parameter to a function which perform the calculation, the result never comes right, like below: int...
3
by: Shark1 | last post by:
Hello. I'm suppose to write a program that will match the price given by the user using the least number of coins. There are 5 different type of coins. I get this output, the count is...
12
mia023
by: mia023 | last post by:
Hi i have an assignment that i don't understand and need help in. Write a program that reads in a command line integer N(number of pennies) and prints out the best way(fewest number of coins) to...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.