Java Reference
In-Depth Information
*5.49
(
Count vowels and consonants
) Assume letters
A
,
E
,
I
,
O
, and
U
as the vowels.
Write a program that prompts the user to enter a string and displays the number
of vowels and consonants in the string.
Enter a string: Programming is fun
The number of vowels is 5
The number of consonants is 11
*5.50
(
Count uppercase letters
) Write a program that prompts the user to enter a string
and displays the number of the uppercase letters in the string.
Enter a string: Welcome to Java
The number of uppercase letters is 2
*5.51
(
Longest common prefix
) Write a program that prompts the user to enter two
strings and displays the largest common prefix of the two strings. Here are some
sample runs:
Enter the first string: Welcome to C++
Enter the second string: Welcome to programming
The common prefix is Welcome to
Enter the first string: Atlanta
Enter the second string: Macon
Atlanta and Macon have no common prefix
Search WWH ::
Custom Search