Question: Objectives : Working with Strings, character, and loops. Disemvoweling Disemvoweling is the process of removing all vowels from a piece of text to make it
Objectives: Working with Strings, character, and loops.
Disemvoweling
Disemvoweling is the process of removing all vowels from a piece of text to make it shorter. This is often used in text messaging or tweeting when the length of messages is limited. Usually the resulting message can still be understood but this technique allows you to squeeze in a little more text than you otherwise could. You are going to write a program to read a line of input from the console and then disemvowel it. Here is an example execution:
Welcome to the disemvoweling utility. Enter your phrase: Computer Science has wicked cool assignments! The disemvoweled phrase is: Cmptr Scnc hs wckd cl ssgnmnts! Reduced from 45 to 31 characters. Reduction rate of 31%
Part 1 (10 points) Reading the input
First just set up the prompting and reading of the input. Use a Scanner object on System.in and use the .nextLine() method to read in the input as a single string. At this point simply print out the original string as verification that the reading is working.
Part 2 (10 points) Disemvoweling
Now loop through the string character by character looking for the vowels. You can use the string method .charAt(index) to get each character. Testing if a character is a vowel would be easy if the Character class had an isVowel(ch) method, but unfortunately it doesn't. Instead, you can use a sequence of if-else statements, or a singe if statement with a compound condition, or a switch statement.
Just print the non-vowels as you find them, but also count the vowels. This vowel count will be useful for the statistics in the next part.
Part 3 (10 points) Statistics
Print the statistics as shown above: the original number of characters, the number of characters in the disemvoweled phrase and the percentage reduction.
Extra Credit (5 points) Eliminating double letters
A further way to reduce characters is to eliminate repeated letters. In the example above, "Assignments" would become "sgnmnts". The word "Mississippi" would become "Msp". Implement this additional feature. For testing make up a meaningful sentence using the words "assassinate", "Mississippian", "possesses", and "statuette".
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
