Your cart is currently empty!
Preparation No lesson this week Read text chapter 9 For Credit I’m not requiring the MyProgrammingLab exercises for this chapter, but you may want to complete them anyway as preparation for the assignment and final exam. Assignment 10.1 [95 points] The WordCruncher class Write the Java code for…
Preparation
For Credit
I’m not requiring the MyProgrammingLab exercises for this chapter, but you may want to complete them anyway as preparation for the assignment and final exam.
Assignment 10.1 [95 points]
The WordCruncher class
Write the Java code for the class WordCruncher. Include the following members:
A default constructor that sets the instance variable ‘word’ to the string “default”.
A parameterized constructor that accepts one String object as a parameter and stores it in the instance variable. The String must have no whitespace and no punctuation. If the String parameter has whitespace or punctuation, set the instance variable to the string “default” instead. (This restriction will make your work on some of the following methods much easier.)
A method int numLetters() that returns the number of letters in the instance variable.
A method int numVowels() that returns the number of vowels in the instance variable.
A method boolean beginsWithVowel() that returns true if the first letter of the instance variable is a vowel, and false otherwise.
A method String toPigLatin() that returns a String containing the ‘pig latin’ version of the instance variable.
The rules for translating a word to pig latin are:
PIG LATIN IS FUN becomes IGPAY ATINLAY ISWAY UNFAY in pig latin.
A method String toGibberish() that returns a String containing the ‘gibberish’ version of the instance variable. The rules for translating a word into gibberish are:
A method String reverse() that returns a String that contains the characters of the instance variable, but in reverse.
A method int numCharOccurrences(char ch) that returns a count of the number of times the parameter char ch occurs in the instance variable.
The application
Write a class named WordCruncherTest that has only a main method that:
The program should continue to do this until the user enters the word “quit”
Submit Your Work
Execute the program and copy/paste the output into the bottom of your WordCruncher.java file, making it into a comment. Send an email to ta.sanmateo@gmail.com with the subject “CIS 254 a10”. Attach your two files to the email. In the body of the email let me know whether the programs work as required.
Keep in mind that if your code does not compile you will receive a 0.
Note that the gmail email account is for homework submission only. The account is not monitored for any other purpose.
Assignment 10.2 [5 points]
Participate in the assignment 10 discussion. This could involve asking a question, answering another student’s question, giving an example of something that you struggled with and then overcame (or didn’t!), giving an example of something you found particularly cool, or any other constructive way you can think of to participate.