Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

I Don't Get It


  • Please log in to reply
2 replies to this topic

#1 chlazzaro177

chlazzaro177

  • Members
  • 109 posts
  • OFFLINE
  •  
  • Local time:01:17 PM

Posted 03 April 2007 - 10:21 PM

So I am doing this project where i have to convert pennies into Dollars, Quarters, Dimes, and Nickels.
I am using Integer Division and Mod Arithmetic. I read the chapter that i am doing and there is a short paragraph about it that doesn't really help me.

Heres a line of code i did

Me.uiMessageLabel.Text = Pennies \ 100 & " dollars " & Pennies Mod 4 & " quarters"

I enter 1875 into my program and it shows and I get 18 dollars and 3 quarters.

When I punch in 1877 I get 18 dollars and 1 quarter.

What am I doing wrong?

BC AdBot (Login to Remove)

 


m

#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:17 PM

Posted 03 April 2007 - 10:45 PM

77 mod 4 is 1. That's what you told it to do, and that is what it did. :thumbsup: What were you expecting?

77/4 = 19.25 with a remainder of 1. That's what the mod function does; it returns the remainder.

EDIT: 75 mod 4 equals three, so you only accidentally got the right number.

#3 chlazzaro177

chlazzaro177
  • Topic Starter

  • Members
  • 109 posts
  • OFFLINE
  •  
  • Local time:01:17 PM

Posted 03 April 2007 - 10:53 PM

Yeah I figured out what I did was wrong I was going to delete the post but I didn't know how to do it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users