#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Help with Countdown Program


    HI I'm currently working on a program to simulate the TV show countdown. Basically I need it to ask for 8 vowels or consonants then display the largest matched words from a seperate text file. I've got it working up until displaying the words, i can;t get it to show up the right thing. Any help would be appreciated.
    This is what I've got for the matched words part:

    public static void matchWords(){
    String countdownLetters = userLetters.toString();

    //words
    for(int i=0; i <wordLists.length - 1; i++){
    // letters in word
    int wordLength = wordLists[i].length() - 1;
    String word = wordLists[i];
    int matchedLetters = 0;

    System.out.print(countdownLetters);

    for(int j=0; j<wordLength; j++){
    char letter = word.charAt(j);



    if(countdownLetters.indexOf(letter) >= 1){
    matchedLetters = matchedLetters + 1;


    if(matchedLetters == wordLength){
    //matched word
    System.out.println(word);
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    i can;t get it to show up the right thing
    Please explain. What does the program display now? What should it display?

    Please edit your post and wrap your code with code tags
    [code ] (without space after e)
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0
    Sorry, It displays a list of words with any matching letter, when it's supposed to show the longest word containing the chosen letters
    Code:
    public static void matchWords(){
    String countdownLetters = userLetters.toString();
    
    //words
    for(int i=0; i <wordLists.length - 1; i++){
    // letters in word
    int wordLength = wordLists[i].length() - 1;
    String word = wordLists[i];
    int matchedLetters = 0;
    
    System.out.print(countdownLetters);
    
    for(int j=0; j<wordLength; j++){
    char letter = word.charAt(j);
    
    
    
    if(countdownLetters.indexOf(letter) >= 1){
    matchedLetters = matchedLetters + 1;
    
    
    if(matchedLetters == wordLength){
    //matched word
    System.out.println(word);
  6. #4
  7. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,696
    Rep Power
    347
    Can you post the program's output and explain what is wrong with it and show what it should be?

    Please edit the post and format the code. Not all statements should start in the first column. Nested statements should be indented 3-4 spaces.

IMN logo majestic logo threadwatch logo seochat tools logo