my dog learned polymorphism
The moose likes Beginning Java and the fly likes Characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Characters" Watch "Characters" New topic


Becky Miller

Joined: Jan 24, 2001
Posts: 17
I need to write a program to generate a random sequence of capital letters that does not include vowels.

So far I only have this

public class Letters{
public static void main(String [] args)
symbol= (char)(26.0 * Math.random());
can anyone help?
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 782

char ch;
ch = (char) (65 + (Math.random() * 26));
Well the function above generates pseudo random capital letters. In terms of the non-vowel requirement - beats me.
[This message has been edited by Pho Tek (edited February 18, 2001).]


Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

It seems to me you will have to check for the specific numbers that represent those letters. I dont have a table of them but what I would probably do is use a switch statement. Capital A would apparently be 65

not a complete solution but should give you an idea.

Visit my download page
I agree. Here's the link:
subject: Characters
It's not a secret anymore!