someone can teach me about the random genrated?
let say i would like to generate a random number between 100 to 200 and store it into one integer variable, what is the code??????
check out the following code, is that your requirement?
[HTML] class RandomGen
{
public static void main(String args[])
{
int i=(int)(100+((int)Math.round(100*Math.random())));
System.out.println(i);
}
}
[/HTML]
regards
srinivas
check out the following code, is that your requirement?
[HTML] class RandomGen
{
public static void main(String args[])
{
int i=(int)(100+((int)Math.round(100*Math.random())));
System.out.println(i);
}
}
[/HTML]
regards
srinivas
thank you very much
this is what i need for the output
but can u explain to me more detail about this code how it run?
like the Math.round, why u need use this? and how u make the range between 100 to 200? if between this range i need to include the 200 so how
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.