Download Java and java Official Website
Generate a random letter to determine whether it is a vowel or a consonant.
[) + Offset 'A' to generate lowercase letters.
Code:
//: Main. javaimport java. util. random;/*** determine the vowel consonants */class Main {public static void main (String [] args) {Random rand = new Random (47 ); for (int I = 0; I <10; I ++) {int c = rand. nextInt (26) + 'a'; System. out. println (char) c + "," + c + ":"); switch (c) {case 'A': case 'E': case 'I ': case 'O': case 'U': System. out. println ("vowel"); break; case 'y': case 'W': System. out. println ("Sometimes a vowel "); Break; default: System. out. println ("consonant") ;}}}/*** Output: y, 121: Sometimes a vowel n, 110: consonant z, 122: consonant B, 98: consonant r, 114: consonant n, 110: consonant y, 121: Sometimes a vowel g, 103: consonant c, 99: consonant f, 102: consonant *///:~
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.