How can I Make a random character with numbers and letters but capital and lower case without using an array.
Random Number and Letter generatorRandom Number and Letter generator
Page 1 of 1
3 Replies - 31361 Views - Last Post: 04 February 2009 - 11:35 PM
Replies To: Random Number and Letter generator
#2
Re: Random Number and Letter generator
Posted 04 February 2009 - 08:23 PM
Take a random number between where the start of lower case a is and the end of 9 is and then cast it to a char.
For more information post your best attempt like so:

We won't do your homework for you, so, thanks for helping us help you.
For more information post your best attempt like so:
We won't do your homework for you, so, thanks for helping us help you.
#3
Re: Random Number and Letter generator
Posted 04 February 2009 - 08:26 PM
#4
Re: Random Number and Letter generator
Posted 04 February 2009 - 11:35 PM
to make random numbers, you can use the Math.Random() function which can be used as: int Random = (int)(Math.random() * max) + min; where max and min are the highest and lowest numbers in the range respectively, to make random alphabet characters without using arrays, you can create a String variable and add to it all the alphabets and then use Math.random() to get a character randomly from the string, here is a brief example:
hope this helps, good luck
String alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int character=(int)(Math.random()*26); String s=alphabet.substring(character, character+1);
hope this helps, good luck
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|