Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Beginner Java Program help please!

Computer Science
I got my questions answered at in under 10 minutes. Go to now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly


Get your free account and access expert answers to this and thousands of other questions

I'm really confused in what I have to do... Basically we create a word game. The user enters a word, like "Apartment" Then our program checks to see if any of the words in it's "dictionary" can be created from the letters in the word just entered. The words in my dictionary are: hat, pool, math, bita, sheep, cap, dog, cat, one, eat, ear; We haven't learnt how to use arrays yet and are not supposed to use them. Im not sure what to do after the user enters the word.. :s
You could store them all inside a large String. String dictionary = "hat pool math bita sheep cap dog cat one eat ear"; Then do something like: if( dictionary.indexOf(input) > 0) System.out.println("Word exists"); else System.out.println("Word doesn't exist"); Look into indexOf, im pretty sure you can send a string as argument, what it does it check inside the String dictionary for a certain char or String of chars you send it, if it finds it, it'll return the position where it found it. If it doesn't, it'll return -1.
That's good stuff. It doesn't print out the word it found, though. You have the index, just look for the first space. Print out the substring from index of the word to the next space.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Without arrays it's a real PITA. Here's one way to do it. You'll need these functions: int getLetterCount(String word, char letter); // return the number of times letter occurs in word boolean testLetter(String userWord, String dictionaryWord, char letter); // return true if userWord has more of letter than dictionaryWord boolean containsWord(String userWord, String dictionaryWord); // return true if userWord has more of every letter than dictionaryWord void printMatchingWords(List dictionary, String userWord); // for each word in dictionary, prints it if containsWord(userWord, word) returns true I don't know how you're storing the dictionary, but it's hard to do without an array or a Collection. In main you'd get the user's word, then call printMatchingWords with that word and the dictionary. This is incredibly inefficient. If you could use an array it would be much better. I don't know what other data types you can use, so I assumed you could only use individual primitives.

Not the answer you are looking for?

Search for more explanations.

Ask your own question