Random Number and Letter generator

Random Number and Letter generator

Page 1 of 1

3 Replies - 37152 Views - Last Post: 04 February 2009 - 11:35 PM Rate Topic: -----

#1 Bmxr586  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-February 09

Random Number and Letter generator

Post icon  Posted 04 February 2009 - 07:14 PM

How can I Make a random character with numbers and letters but capital and lower case without using an array.
Is This A Good Question/Topic? 0
  • +

Replies To: Random Number and Letter generator

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,148
  • Joined: 07-September 06

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:
:code:

We won't do your homework for you, so, thanks for helping us help you.
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Random Number and Letter generator

Posted 04 February 2009 - 08:26 PM

View PostBmxr586, on 4 Feb, 2009 - 06:14 PM, said:

How can I Make a random character with numbers and letters but capital and lower case without using an array.

Wouldn't qualified this post as "intermediate"

Use the LotoNumber generator in the Code Snippet and pass as argument 'a' and 'z'
Was This Post Helpful? 0
  • +
  • -

#4 ayman_mastermind  Icon User is offline

  • human.setType("geek");
  • member icon

Reputation: 126
  • View blog
  • Posts: 1,860
  • Joined: 12-December 08

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:
 String alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 int character=(int)(Math.random()*26);
 String s=alphabet.substring(character, character+1);


hope this helps, good luck ;)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1