Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-17-2003, 11:33 AM   PM User | #1
g00fy
New Coder

 
Join Date: Jan 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
g00fy is an unknown quantity at this point
math problem with java

hi to all,

i have written a simple calc that displays times tables or it generates random problems of different operators (i.e., + - x /)
the problem is the random numbers that are generated do not always result in an integer answer, so u get problems like 10 / 7 = 1. if i use doubles the answer is 1.42857......... but this is for a forth class student so i only want problems that will result in an integer answer that is correct not like 10 / 7 = 1.


is there an easy waay to do this.


apart from this my first console attempt works fine just need to adapt to applet.


thanx to all in advance

kind regards,

g00fy
g00fy is offline   Reply With Quote
Old 02-17-2003, 07:39 PM   PM User | #2
Josh Campbell
New Coder

 
Join Date: Jun 2002
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Josh Campbell is an unknown quantity at this point
when you are dividing, first check to see if the two numbers produce a remainder. If they do, pick new numbers.

You use the mod operator % to find remainder. If randomIntA % randomIntB == 0 then there is no remainder.
Josh Campbell is offline   Reply With Quote
Old 02-18-2003, 02:05 AM   PM User | #3
g00fy
New Coder

 
Join Date: Jan 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
g00fy is an unknown quantity at this point
thanx josh,

i had a blackout and couldnt get online

but i already figured it out by using the modulus

great minds think alike


thanx again

cheers,


g00fy
g00fy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:24 PM.


Advertisement
Log in to turn off these ads.