participate


Java Programming [Archive] - How many times a number can be devided by twohundred plz help!!
<<   Back to Forum  |   Give us Feedback
10 Duke Stars rewarded for this thread
This topic has 12 replies on 1 page.
wannabejavaking
Posts:22
Registered: 1/27/03
How many times a number can be devided by twohundred plz help!!   
Jan 29, 2003 4:36 AM

 
I need to know how to make the applet calculate how many times a number for example 605 can be diveded by 200. The anwser is 3 but how can i make the applet calculate this

plz help!!!!
 
magnus_ahl
Posts:23
Registered: 7/26/02
Re: How many times a number can be devided by twohundred plz help!!   
Jan 29, 2003 4:45 AM (reply 1 of 12)  (In reply to original post )

 
Ehh... do you mean like this?

int answer = 605 / 200;
 
slippyr4
Posts:1
Registered: 12/19/02
Re: How many times a number can be devided by twohundred plz help!!   
Jan 29, 2003 4:48 AM (reply 2 of 12)  (In reply to original post )

 
You're not making 100% sense here.

How many times can 605 be divided by 200? the answer is infinate times, with progressively smaller results:-

605 / 200 = 3.025
3.025 / 200 = 0.015125

etc etc. you can keep going for ever.

I wonder if you actually mean how can i divide 605 by 200 (using integers only) ?

in the which case:-

int result = 605 / 200; // result now contains 3

this is of course as opposed to:-
float result = 605 / 200; // result contains 3.025

Hope that helps.
 
wannabejavaking
Posts:22
Registered: 1/27/03
Re: How many times a number can be devided by twohundred plz help!!   
Jan 29, 2003 4:49 AM (reply 3 of 12)  (In reply to #1 )

 
yes but then i need to have two remainings

int value = (5 because 605-600=5)
int result = (3 not 3,1 its got to be rounded to the lowest number always)

how can you do that
 
wannabejavaking
Posts:22
Registered: 1/27/03
Re: How many times a number can be devided by twohundred plz help!!   
Jan 29, 2003 4:50 AM (reply 4 of 12)  (In reply to #1 )

 
yes but then i need to have two remainings

int value = (5 because 605-600=5)
int result = (3 not 3,1 its got to be rounded to the lowest number always)

how can you do that
 
wannabejavaking
Posts:22
Registered: 1/27/03
Re: How many times a number can be devided by twohundred plz help!!   
Jan 29, 2003 4:56 AM (reply 5 of 12)  (In reply to #4 )

 
you have to excuse me for my english because it is not so good.

ill try to explain why i need this

i have to make a payment machine where you can enter a number and it will pay you bills.

it must always pay you the largest possible bill first and the the smaller one etc etc.

so if you type 650 it has to pay you

1x 500
1x 100
1x 50

and not

6x 100
1x 50
 
ikohl
Posts:5
Registered: 9/27/02
Re: How many times a number can be devided by twohundred plz help!!      
Jan 29, 2003 5:00 AM (reply 6 of 12)  (In reply to #4 )

 
for (i=1, i<1000, i++) {
if 605/i*200 < 200 break..
so i would be the 3
 
rohankamat
Posts:197
Registered: 2/7/01
Re: How many times a number can be devided by twohundred plz help!!   
Jan 29, 2003 5:04 AM (reply 7 of 12)  (In reply to original post )

 
can u please be more clear

rohan
 
VaskoL
Posts:778
Registered: 10/2/99
Re: How many times a number can be devided by twohundred plz help!!      
Jan 29, 2003 5:13 AM (reply 8 of 12)  (In reply to #6 )

 
for (i=1, i<1000, i++) {
if 605/i*200 < 200 break..
so i would be the 3

ROFLMAO (not at the code, but at the dukes)

you actually get the same result when you do just
int result = 605 / 200; // result == 3
and if you want that reminder then you just
int reminder = 605 % 200; // reminder == 5

for making it more clear:
int result = 29 / 10; // result == 2
int reminder = 29 % 10; // reminder == 9

you see, that result never gets rounded up.
 
ikohl
Posts:5
Registered: 9/27/02
Re: How many times a number can be devided by twohundred plz help!!   
Jan 29, 2003 5:13 AM (reply 9 of 12)  (In reply to #7 )

 
ok

I multiplicate 200 as often as I reach a number thats lower than 200.
The result is how often I had to multiplicate 200.
 
ikohl
Posts:5
Registered: 9/27/02
Re: How many times a number can be devided by twohundred plz help!!   
Jan 29, 2003 5:17 AM (reply 10 of 12)  (In reply to #9 )

 

I multiplicate 200 as often as I reach a number thats lower than 200.
The result is how often I had to subtract 200.

605 - 200 - 200 - 200 = 5 < 200
0 1 2 3 .. the result is 3
 
wannabejavaking
Posts:22
Registered: 1/27/03
Re: How many times a number can be devided by twohundred plz help!!   
Jan 29, 2003 5:21 AM (reply 11 of 12)  (In reply to #10 )

 
thanx ikohl taht really helped a lot

it works just fine know
 
ikohl
Posts:5
Registered: 9/27/02
Re: How many times a number can be devided by twohundred plz help!!   
Jan 29, 2003 5:22 AM (reply 12 of 12)  (In reply to #11 )

 
please

I enjoyed helping you
 
This topic has 12 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 26
  • Guests : 122

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums