Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- /**
- *
- * @author kavinsan
- *
- */
- public class FindCat {
- public static void main (String[] args)
- {
- createWord();
- }
- /**
- * Creates the word cat
- * @return word
- */
- public static String createWord ()
- {
- String vowel = "aeiou";
- String consonant = "bcdfghjklmnpqrstvwxyz";
- int k = 0;
- String word;
- String firstWord;
- String secondWord;
- String thirdWord;
- while(true){
- Random r = new Random();
- k = r.nextInt(21) + 1;
- int i = consonant.length() - k;
- //System.out.println(consonant.charAt(i)); Activate to see if random letter work
- if (i == 1){
- k = 0;
- System.out.println(consonant.charAt(i));//Check if the correct letter is found
- firstWord = consonant.substring(i,i+1);
- break;
- }
- }
- while(true){
- Random r = new Random();
- k = r.nextInt(5) + 1;
- int i = vowel.length() - k;
- //System.out.println(vowel.charAt(i)); Activate to see if random letter work
- if (i == 0){
- System.out.println(vowel.charAt(i));//Check if the correct letter is found
- secondWord = vowel.substring(i,i+1);
- break;
- }
- }
- while(true){
- Random r = new Random();
- k = r.nextInt(21) + 1;
- int i = consonant.length() - k;
- //System.out.println(consonant.charAt(i)); Activate to see if random letter work
- if (i == 15){
- System.out.println(consonant.charAt(i));//Check if the correct letter is found
- thirdWord = consonant.substring(i,i+1);
- break;
- }
- }
- return word;
- word = firstWord + secondWord + thirdWord;
- System.out.println(word);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement