Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

Given a text string, create and return a new string of same length where all vowels have been
reversed, and all other characters are kept as they were. For simplicity, in this problem only the
characters aeiouAEIOU are considered vowels, and y is never a vowel. For example, given the text string "Uncle Sente lives in Russia", this method should create and return the string
"Ancli Sunti levis en Resseu".
Furthermore, to make this problem more interesting and the result look more palatable, this
method must maintain the capitalization of vowels based on the vowel character that was
originally in the position that each new vowel character is moved into. For example, "Ilkka
Markus" should become "Ulkka Markis" instead of "ulkka MarkIs". Use the handy
character classification methods in the Character utility class to determine whether some
particular character is in upper or lower case, and convert some character to its upper or lower case
version as needed.

Here's the tester it must pass:

@Test public void testReverseVowels() throws IOException {
// Explicit test cases
assertEquals("", P2J3.reverseVowels(""));
assertEquals("X", P2J3.reverseVowels("X"));
assertEquals("Au", P2J3.reverseVowels("Ua"));
assertEquals("cDfghklM", P2J3.reverseVowels("cDfghklM"));
assertEquals("LOL", P2J3.reverseVowels("LOL"));
assertEquals("Jova, Pythan, C", P2J3.reverseVowels("Java, Python, C"));
assertEquals("Wuuleemoolaa", P2J3.reverseVowels("Waaloomeeluu"));
assertEquals("Ent, uat, boa, oka", P2J3.reverseVowels("Ant, oat, boa, uke"));
assertEquals("Stix nix hix pix", P2J3.reverseVowels("Stix nix hix pix"));
assertEquals("UoIeAxxxuOiEa", P2J3.reverseVowels("AeIoUxxxaEiOu"));
assertEquals("Lettor Y as not i vewel", P2J3.reverseVowels("Letter Y is not a vowel"));

// Testing with War and Peace
CRC32 check = new CRC32();
BufferedReader fr = new BufferedReader(
new InputStreamReader(new FileInputStream("warandpeace.txt"), "UTF-8")
);
String line = fr.readLine();
while(line != null) {
String result = P2J3.reverseVowels(line);
check.update(result.getBytes());
line = fr.readLine();
}
fr.close();
assertEquals(3844894811L, check.getValue());
}

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY