Need Mod Help

JennerStyle

Member
Joined
Jul 26, 2004
Messages
6
Programming Experience
Beginner
This is my first time in working with VB.Net and I have hit a big snag to me at least! :)

The assignment reads:

"Write a program that will display the number of dollars and cents in two output TextBox controls based on user numeric input. For instance, if the user inputs 543, the program will display the 5 in the Dollars output TextBox control and the 43 in the Cents output TextBox control. For this program, use integer arithmetic and avoid using decimal variables and values. If necessary, review the integer remainder modular operator, Mod, introduced in this chapter. The completed application should display as shown in Figure 4-64"

I am using 'Microsoft Visual Basic.Net Comprehensive Concepts and Techniques' by Shelly Cashman Quasney.

I could really use some help because this one assignment is making no sense to me the way the book explains it.

Thank you in advance :)

Jennifer
 
Last edited:

levyuk

Well-known member
Joined
Jun 7, 2004
Messages
313
Location
Wales, UK
Programming Experience
3-5
Although homework is not answerred for you, if you just try and do something and ask questions that you get stuck on then you will get some help. My advice to you is to just try and learn something by using an online tutorial.
 

JennerStyle

Member
Joined
Jul 26, 2004
Messages
6
Programming Experience
Beginner
I don't want ANSWERS!

Look, maybe I am being misunderstood here......I don't want a free handme out code! I want to understand how to do this! I have read and re-read the section in the chapter referring to this and it talks about A=2/3/4 mod 2 so on and so on but I don't understand what the outcome is of what it is saying!

I'm sorry for seeming to be asking for handouts - I just put the problem in there because I thought it would make it easier to understand what is supposed to be done! When I found this forum, it was shown as a forum that provided help and advice on coding....that's why I posted here! I DON'T WANT AN ANSWER I WANT TO UNDERSTAND HOW, WHY, AND WHAT I AM SUPPOSED TO DO! I believe I even said " I could really use some help because this one assignment is making no sense to me the way the book explains it"
 

JennerStyle

Member
Joined
Jul 26, 2004
Messages
6
Programming Experience
Beginner
To levyuk

You are exactly right and I spent 3 hours last night reading and rereading that section of the Chapter trying to understand! I stated this is my first time with VB.net and why do you think I posted here? I'm asking for HELP! Nowhere in my original post did I say "Can someone give me an ANSWER?" NO! I said " I could really use some help because this one assignment is making no sense to me the way the book explains it"!

Sorry, I'm a bit frustrated with this whole thing because I only want to UNDERSTAND what I am to do and I entered the problem to better explain what is being requested!
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
You're right, this is the perfect place to come for help with any VB.NET code. I believe mzim had good intentions.

To answer your question; the Mod operator divides two numbers and returns only the remainder. For example:

myResult = 10 Mod 5 ' Returns 0.
myResult = 10 Mod 3 ' Returns 1.

To get the cents part, use the Mod operator to divide the entered value by 100. The returned part will be the cents.

To get the dollars part, subtract the result of the Mod operation from the entered value and divide by 100

Let us know if you are still having problems :).
 

JennerStyle

Member
Joined
Jul 26, 2004
Messages
6
Programming Experience
Beginner
ok let me see if i have this

Ok. I understand to use mod 100 to get the cents......this would be very easy if there was a given amount (LOL) and it was always the same (LOLOLOL)! So let me try this:

(we will say it's a txtbox that the answer is going in and the input numbers are txtnumbers.txt for right now)

txtcents = 100 Mod / txtnumbers.txt
txtdollars = txtcents - txtnumbers / 100


Am I close????? I know I understand what you are saying a bit more now.......please tell me I'm close :)
 

levyuk

Well-known member
Joined
Jun 7, 2004
Messages
313
Location
Wales, UK
Programming Experience
3-5
VB.NET:
[/size][size=2][color=#0000ff][/color][/size]
[size=2][color=#0000ff]Dim[/color][/size][size=2] i [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]Integer[/color][/size]
[size=2][color=#0000ff]Dim[/color][/size][size=2] result [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]Integer[/color][/size]
[size=2]i = TextBoxNumber.Text[/size]
[size=2]result = i [/size][size=2][color=#0000ff]Mod[/color][/size][size=2] 100[/size]
[size=2]TextBoxCent.Text = result[/size]
[size=2]TextBoxDollar.Text = ((i - result) / 100)[/size]
[size=2]

This is how I work it out
The original number is entered into a box, once a button is clicked the number entered is placed into the 'i' variable.
From there we can work out the cent's by using 'mod'
Then we take away the cent's from the number that was entered, divide what is left by 100 and then you have your dollars.
 
Top Bottom