Posted by Ben on Friday, May 28, 2010 at 7:29am.
1.
Check with your teacher if the list is supposed to be case sensitive. From the context of the question, it should not be.
In this case, convert all the strings into lowercase and compare using the String.toLowerCase() method before comparison.
The comparison can be done character by character using the String.charAt(i) method.
Use an array of size 26 to store the frequencies. Do not forget to initialize the array (or the Frequency class values).
Read the Java API for more details.
http://java.sun.com/javase/6/docs/api/
or to download the API to your computer:
http://java.sun.com/javase/downloads/index.jsp#docs
2.
First compare the lengths of the successive words using String.length().
If they equal, then compare letter by letter, and count the number of different letters. If the difference equals 1, continue the "ladder".
You may have to convert all letters to lowercase before the comparison.
3. There are plenty of algorithms for finding prime numbers. One of them is to test the divisibility by primes. You will have to create a list of primes, starting with 2, which is assumed to be a prime. Test all odd numbers starting from 3. Whenever you find that the number does not divide by the numbers on your prime list, you have found a prime, and add it to your prime list.
For example 3 does not divide by 2, so add 3 to the prime list. 5 does not divide by 2 and 3, add it to the prime list. Likewise, 7 is added to the prime list. 9 divides by 3, so skip it.
11 does not divide by 2,3... so it is a prime.
You do not have to test all the primes on the prime list. If the square of the prime on the prime list exceeds the number X to be tested, X can be declared a prime. For example, for 11, it is not divisible by 2,3, but 5²>11, so 11 can be declared a prime.
It may sound complicated, if you post your pseudocode or the Java code, you can get further help.
Related Questions
computer science - Hey I have three questions with creating these methods can ...
computer science - Write a method main that demonstrates class Employee's ...
probability - out of 250 students interviewed at a community college, 90 were ...
Calculus - Let f be a one-to-one function whose inverse function is given by the...
COMPUTER SCIENCE JAVA - Assignment problems: Write Java programs for each of the...
COMPUTER SCIENCE JAVA - Assignment problems: Write Java programs for each of the...
socials - Question:Hey I posting for my brother Mohammad again, his computer ...
science - An area in your state has been flooded due to heavy rains. How might ...
computer science - Hi what are mutator and accessor methods and what is the ...
Kindergarten trip sheet - My kindergarten class is taking a trip to the New York...
For Further Reading