CS 171 & 171L Introduction to Computer Science I & Lab Fall 2017 

String Processing

In this project, you will write methods that will process strings.

Goals

The main goal of this exercise is to get you more familiar with using Strings and loops. You will do this by writing several methods that process strings.

Task

Put all of the methods below into a single class and create a main method that tests each function for at least 5 inputs.
  1. (4 points) Write a method isDigit that takes a char and returns a boolean if the input char is a digit (0,1,2,...9).

  2. (4 points) Write a method called distance that takes two Strings and determines the number of positions in which the Strings differ. If the strings do not have the same length, return -1. If the Strings are equal, return 0.
    For example, the words "computer" and "commuter" differ in one place and your function should return a 1. The words "computer" and "executer" differ in 4 locations. The words "computer" and "statutes" differ in 5 locations.

  3. (4 points) Write a method called oodle that takes a String parameter and converts every vowel into the String "oodle". Assume all letters are lower case.
    For example, "albion" becomes "oddlelboodleoodlen".
    DO NOT use the replace method of String! Use a loop and the charAt method.

  4. (4 points) Write a method allTheVowels that takes a single string parameter and returns true if the input string contains all the vowels (a,e,i,o,u).
    For example, the words "authorize", "unorganized", and "facetious" each contain all of the vowels exactly once.
    The word "albion" does not contain all the vowels.
    Hint: Use a int counting variable for each vowel.

  5. (4 points) Write a method hasDoubleLetter that takes a single String parameter and returns true if it contains two identical letters in a row.
    Example words include "book", "tree", "beeswax", "poodle", and "puddle".
    Hint: Avoid going beyond the end of the string!

Extra Credit

  1. (4 points) Write a method called isPangram which takes a single String parameter and returns true if the input String is a pangram (a word or phrase containing all letters of the alphabet).
    For example, the sentence "Pack my box with five dozen liquor jugs." is a pangram. Another is "The five boxing wizards jump quickly." Yet another is "The quick brown fox jumps over the lazy dog"
    Hint: Use a int counting variable for each letter.

  2. (4 points) Write a method called isIsogram which takes a single String parameter and returns true if the input String is an isogram (a word or phrase containing no more than one occurrence of any letter).
    For example, the words "computer" and "albion" are isograms. The words "bookkeeper" and "Michigan" are not isograms.
    Hint: Use a int counting variable for each letter.

Notes

Unless otherwise indicated, you can use the length, charAt, toUpperCase, toLowerCase, indexOf, substring (both varieties), and other methods of String if you find them helpful. Do not use arrays, even if you have used them before.

Deliverables

You will need to submit your java code (NOT .class file) to me electronically as an email attachment.


Copyright © 2017, David A. Reimann. All rights reserved.