answersLogoWhite

0


Best Answer

public class Capitals {

public static void main(String args[]) {

int counter = 0; // Counter for number of capitals generated.

int numberToGenerate = 20; // Number of capitals to generate.

char symbol = 0; // Variable to store a random character.

// While there are still letters to generate:

while( counter < numberToGenerate ) {

// Generate a random symbol between A and Z:

// This relies on the fact that the codes for the letters are in a

// contiguous sequence from 'A' to 'Z'. If we add 1 to 'A' we get the

// code for 'B', if we add 2 we get 'C', and so on. Thus to create a

// random capital letter from 'A' to 'Z' we can add a random integer

// between 0 and 25 to 'A'.

symbol = (char)(26*Math.random() + 'A');

switch(symbol) {

//Vowels ignored:

case 'A':

case 'E':

case 'I':

case 'O':

case 'U':

break;

default:

//Consonant displayed:

System.out.print(symbol + " ");

counter++;

break;

}

}

}

}

by:- Munawar Ali bhurgri from Badin

0300-2490262

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to generate a random sequence of capital letters that does not include vowels in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you read the number of capital letters in a input file using c language?

#include &lt;stdio.h&gt; #include &lt;ctype.h&gt; ... int caps = 0; int c; file = fopen ("InputFile", "r"); while ((c = fgetc (file)) != EOF) { if (isupper (c)) ++caps; } fclose(file); ...


How do you sort letters in java?

Let us assume by "alphabet letters arrays" you mean you have an array of chars. char[] letters = //some character array Arrays.sort(letters); // Letters is now sorted. // Note that letters will be sorted according to the ASCII values // of the chars. This means that all capital letters will be sorted // before lower case. ('Z' will come before 'a')


How many unique values can you assign in a 3 byte alphanumeric field?

There are 26 alphabetic characters (a-z) and 10 numeric (0-9) which together form 36 alphanumeric characters. If you include capital letters, then you have 62 (36 + 26) alphanumeric characters. 62 * 62 * 62 = 238,328


Can identifier be any sequence of digits and letters?

If you mean a variable name, then no -- it must begin with a letter or an underscore, but any combination of letters, digits and underscores may follow. If you mean a variable that stores an identifier, then yes -- so long as the identifier is a string type.


What are the rules of creating identifier?

Identifiers refers to the names of variables, functions and array. These are user defined names and consist of a sequence of letters and digits, with a letters as a first character.Both uppercase and lowercase letters are permitted, although lowercase letters are commonly used. The underscore character is also permitted in identifiers. It is usually used as a link between two words in long identifiers. In C, identifiers may contain any alphanumeric characters (a-z, A-Z, 0-9) as well as underscores (_), but must not begin with a number.

Related questions

What capital letters have curves?

Capital letters with curves include letters like C, D, G, J, and S. These letters have rounded or circular elements in their shapes.


Why are these letters separated by a line aefhiklmntvwxyz bcdgjopqrsu?

When capital, the sequence beginning with 'A' are all written with only straight lines.


What countries have 4 letters and 4 letters in the capital?

Fiji has four letters and its capital, Suva has four letters. :) Peru; capital is Lima Togo; capital is Lom&eacute;


How many capital letters are in the preamble?

16 capital letters


IS re small or capital letters?

re is small letters; RE is capital letters.


Which state capital has tree letters in it?

No state capital has a total of three letters or just three letters.


What letter comes next BCDGJ?

QuestionWhat letter comes next in the sequence 'BCDGJ' ? AnalysisSequences are often arithmetic, but there does not appear to be an arithmetic sequence to this set of letters.The missing letters areA_ _EF_HI_ . Notice that all these capital letters are formed solely by straight lines, whereas _BCD_ _G_ _J are all formed, wholly or in part, by curved lines.A complete list of all 'straight-lined' letters in the English alphabet isA_ _EF_HI_KLMN_ _ _ _ _T_VWXYZ.ResultThe list of capital letters which have curved lines is_BCD_ _G_ _J_ _ _ _ OPQRS_U_ _ _ _ _.ConclusionThe letter letter that comes next in the sequence 'BCDGJ' is the letter O.


Does name of a capital city to be written with capital letters?

Does name of a capital city to be written with capital letters? In: Uncategorized[Edit categories]


What is represented by capital letters angle or side?

Angles are represented by capital letters. Small letters refer to sides.


When we use capital letters before sentences?

We use capital letters at the beginning of the sentence.


What is the word that start with gen?

Many words begin with the letters gen. A few of those words include gender, general, generate, generation, generate, generosity, generous, genetic, genial, genius, gentle, genteel, gentle, gentlemen and genuine.


What letters are next in sequence jfmamjjasond?

jason