Due: 2024-09-31 23:59:00EDT
In this assignment you will be working with methods, conditionals, and Strings
.
Requirements:
- Every method you created should be tested in the class’s main method.
- Every java file should have a header. However, DO NOT PUT YOUR NAME IN YOUR HEADERS. On gradescope we grade your assignments anonymously so including your name in your Java file will defeat that purpose. However, please include your name in your README.txt
- Every method should contain a javdoc that briefly describes the method, lists the params, and the return type/value. Use the notation that we used in lectures.
- Dont forget to add
public static
to every method signature. If a method does not have these, the autograder will fail and you wont receive any points for that method.
For these methods, you are not allowed to use a loop since we did not cover loops yet. WARNING:Using a loop in a method will result in getting 0 points for that method!
Note, in the examples,
*
indicates user input.
WARNING: In this assignment you are NOT ALLOWED to import any packages. For example, you cannot use the builtin
Arrays
java class to reverse an array. Doing so will result in earning ZERO POINTS for a method that uses it.
IF YOUR CODE DOES NOT COMPILE ON GRADESCOPE, YOU WILL NOT RECEIVE ANY POINTS FROM THE AUTOGRADER. When you submit, make sure to check if the autograder compiles and if you test some of the public test cases.
Although we covered recursion, you are not allowed to use recursion on this assignment. Don’t worry, you will get lots of opportunities this semester to use recursion!
Write a program called WordsWordsWords.java
that implements the following methods. Make sure to test the methods in the file’s main method.
Hint: You will want to use some of the
String
methods covered in the labs.
A word is said to be “abecedarian” if the letters in the word appear in alphabetical order. For example, the following are all six-letter English abecedarian words:
abdest, acknow, acorsy, adempt, adipsy, agnosy, befist, behint, beknow, bijoux, biopsy, cestuy, chintz, deflux, dehors, dehort, deinos, diluvy, dimpsy
Write a method called isAbecedarian
that takes a String and returns a
boolean indicating whether the word is abecedarian.
Your method should only work for words that have 6 letters. If a word does not have 6 letters, the method should return false
.
The method should work for non-alpha numeric characters. For example, the method should return true if the string is 456789
.
A word is said to be a “doubloon” if every letter that appears in the word appears exactly twice. Here are some example doubloons found in the dictionary:
Abba, Anna, appall, appearer, appeases, arraigning, beriberi, bilabial, boob, Caucasus, coco, Dada, deed, Emmett, Hannah, horseshoer, intestines, Isis, mama, Mimi, murmur, noon, Otto, papa, peep, reappear, redder, sees, Shanghaiings, Toto
Write a method called isDoubloon
that takes a string and returns a boolean indicating whether it is
a doubloon. To ignore case, invoke the toLowerCase
method before checking.
Your method should only work for words that have 6 letters. If a word does not have 6 letters, the method should return false
. If the words contains a character that is not an English letter, i.e. a character that is not a-z
or A-Z
, the method should return false
.
Additionally, to make this easier to implement, you should only consider the English letters a-j
. If the word contains a letter that isnt between a
and j
(inclusive), your method can return false
.
Note: 10/02 9:00am - If the word contains a letter that isnt between a and j (inclusive) OR THAT ISN’T BETWEN A AND J, your method can return false.
Isopsephy is the practice of adding up the number values of the letters in a word to form a single number, in Hebrew we often refer to this as Gematria.
Hint: you might find it helpful to create a method that returns the isopsephy value of a word. When often refer to these types of methods as helper methods since they implement some functionality that you use over and over again.
Write a method called avgIsopsephy
that takes in 3 words (strings) and returns a double indicating the average isopsephy value of the words. If any of the words do not contain 4 letters, the method should return -1.
Sample inputs / outputs:
avgIsopsephy("abcd", "efgh", "ijlk") => 26.0
avgIsopsephy("some", "test", "word") => 58.666
Write a method called isopsephySumEqual
that takes in 2 words (strings) and determines if the sums of the isopsephy of each word are equal to each other. The method should return a boolean. Again, if any of the words do not contain 4 letters, the method should return false
.
Write a method called reverseString
that takes in a string and returns the reverse string. If the word does not contain 5 letters, return an empty string.
Hint: String concatenation might be helpful here.
In a text file called README.txt
answer the following questions:
Dont forget: make sure to fill in the header in all of your java files.
Submit the following files to the assignment called HW03
on Gradescope:
WordsWordsWords.java
README.txt
Make sure to name these files exactly what we specify here and name the methods exactly what we specify too. Otherwise, our autograders might not work and we might have to take points off.