Skip to main content

JAVA CODE FOR GENERATE NAMES RESEMBLING REAL NAMES

The below code generates the names with different length by joining the consonances and vowels alternatively.



import java.util.Random;//

/**
 *
 * @author vishnu
 */



 
public class fname { 

        
static Random rnd = new Random();// random is used for randomly select consonance and vowels from given list

static final String CONS = "zxcvbnmlkjhgfdsqwrtyp"; //String which store the consonances 

static final String VOWELS="aeiou";//String which store vowels  
                

public String generateName(int len) //len define length of names 
{
 StringBuilder sb = new StringBuilder(len);
 for( int i = 0; i < len; i++ )
 {
  if(i%2==0)
  sb.append( CONS.charAt( rnd.nextInt(CONS.length()) ) );
  else                                              sb.append(VOWELS.charAt(rnd.nextInt(VOWELS.length())));
 } 

 System.out.println(sb);
 return sb.toString();
 }
       
public static void main(String args[])//
mains function
 {
 fname name=new fname();//
create an object of above class
 System.out.println("name with length 4: "+name.generateName(4));

 System.out.println("name with length 6: "+name.generateName(6));
 }
 }



note: name.generateName(4); will generate name with length 4
and name.generateName(6);  will generate name with length 6

Comments

Popular posts from this blog

FREE DOWNLOAD "Easy YouTube Video Downloader 5.6"

Easy YouTube Video Downloader 5.6 Add-on to quickly and easily download videos from YouTube to your computer. Adds button to download YouTube videos in FLV, MP3, AAC, MP4 and 720p HD and 1080p. 3GP format coming soon. Full-HD qualities.

DANCING GOOGLE

would u ever seen a dancing google web page. A free falling of google.com That's gravity web page, pls do the following steps open www.google.com

What is 3D Printer

What desktop device enables a jewelry designer to manufacture one of a kind designer earstuds and pendants from a CAD file? What device helps the Smithsonian Museum to make hifidelity copies of sculptures to be lent to other museums? How can a highfidelity prototype of a complex mechanical component be created quickly? How can the creative ideas of an architect or designer be converted quickly, accurately and cheaply into a 3D model? What machine can print out human organs such as a blood vessel or a tooth? The answer to all these questions is the 3D printer. A technology that is only gradually becoming popular in the twentyfirst century, 3D printers have attracted the attention of industries  such as mechanical and aeronautical engineering, product designers, architects, and toy manufacturersas well as individuals such as jewelry designers, hobbyists and teachers. The Printing Process The basic process of 3D printing starts with the creation...