0

This a little program that I am making for my little brother how need help in remembering verbs. What its suppose to do at this point in time is pick a word and as the user to then type in the same word but in a different time eg generate run user input running . I have all the words in a 2d array which allows me to compare them . However when I type in the correct answer it say that i am incorrect.

 package javaapplication1;
 import java.util.Random;
 import java.io.*;
 public class JavaApplication1 {

public static void main(String[] args)  throws IOException {
    BufferedReader userInput =
               new BufferedReader(new InputStreamReader(System.in));
    String[][] myArray = { {"awake" , "awoke" , "awoken"},
 {"be" , "was/were" , "been"},
{"beat" , "beat" , "beaten"},
{"become" , "became" , "become"},
{"begin" , "began" , "begun"},
{"bend" , "bent" , "bent"},
{"bet" , "bet" , "bet"},
{"bid" , "bid" , "bid"},
{"bite" , "bit" , "bitten"},
{"blow" , "blew" , "blown"},
{"break" , "broke" , "broken"},
{"bring" , "brought" , "brought"},
{"broadcast" , "broadcast" , "broadcast"},
{"build" , "built" , "built"},
{"burn" , "burned" , "burnt"},
{"buy" , "bought" , "bought"},
{"catch" , "caught" , "caught"},
{"choose" , "chose" , "chosen"},
{"come" , "came" , "come"},
{"cost" , "cost" , "cost"},
{"cut" , "cut" , "cut"},
{"dig" , "dug" , "dug"},
{"do" , "did" , "done"},
{"draw" , "drew" , "drawn"},
{"drive" , "drove" , "driven"},
{"drink" , "drank" , "drunk"},
{"eat" , "ate" , "eaten"},
{"fall" , "fell" , "fallen"},
{"feel" , "felt" , "felt"},
{"fight" , "fought" , "fought"},
{"find" , "found" , "found"},
{"fly" , "flew" , "flown"},
{"forget" , "forgot" , "forgotten"},
{"forgive" , "forgave" , "forgiven"},
{"freeze" , "froze" , "frozen"},
{"get" , "got" , "gotten"},
{"give" , "gave" , "given"},
{"go" , "went" , "gone"},
{"grow" , "grew" , "grown"},
{"hang" , "hung" , "hung"},
{"have" , "had" , "had"},
{"hear" , "heard" , "heard"},
{"hide" , "hid" , "hidden"},
{"hit" , "hit" , "hit"},
{"hold" , "held" , "held"},
{"hurt" , "hurt" , "hurt"},
{"keep" , "kept" , "kept"},
{"know" , "knew" , "known"},
{"lay" , "laid" , "laid"},
{"lead" , "led" , "led"},
{"leave" , "left" , "left"},
{"lend" , "lent" , "lent"},
{"let" , "let" , "let"},
{"lie" , "lay" , "lain"},
{"lose" , "lost" , "lost"},
{"make" , "made" , "made"},
{"mean" , "meant" , "meant"},
{"meet" , "met" , "met"},
{"pay" , "paid" , "paid"},
{"put" , "put" , "put"},
{"read" , "read" , "read"},
{"ride" , "rode" , "ridden"},
{"ring" , "rang" , "rung"},
{"rise" , "rose" , "risen"},
{"run" , "ran" , "run"},
{"say" , "said" , "said"},
{"see" , "saw" , "seen"},
{"sell" , "sold" , "sold"},
{"send" , "sent" , "sent"},
{"show" , "showed" , "shown"},
{"shut" , "shut" , "shut"},
{"sing" , "sang" , "sung"},
{"sit" , "sat" , "sat"},
{"sleep" , "slept" , "slept"},
{"speak" , "spoke" , "spoken"},
{"spend" , "spent" , "spent"},
{"stand" , "stood" , "stood"},
{"swim" , "swam" , "swum"},
{"take" , "took" , "taken"},
{"teach" , "taught" , "taught"},
{"tear" , "tore" , "torn"},
{"tell" , "told" , "told"},
{"think" , "thought" , "thought"},
{"throw" , "threw" , "thrown"},
{"understand" , "understood" , "understood"},
{"wake" , "woke" , "woken"},
{"wear" , "wore" , "worn"},
{"win" , "won" , "won"},
{"write" , "wrote" , "written"}};

    Random rand1 = new Random();

    int  n = rand1.nextInt(88) ;
    System.out.println(n);
    System.out.println("The word is: " + myArray[n][0]);
    System.out.println("Input your answer :");
    String input  = userInput.readLine();
    if (input == myArray[n][1]) {
       System.out.println("Well done"); 
    }
    else{
        System.out.println("Better luck nex time"); 
        System.out.println("The correct answer was : "
                       + myArray[n][1]);
    }
    }

}

Dzyuv001
  • 318
  • 1
  • 6
  • 18
  • 3
    What are you comparing? – Sotirios Delimanolis Nov 07 '14 at 23:43
  • I'm sorry ,i don't come here often. So i don't really know how things work .Can you point me to the solution page than . – Dzyuv001 Nov 07 '14 at 23:51
  • That's also a typical example of the bad use of an array. An array is a low level component, you should not use it this way. In that case, you could for example use an `IrregularVerb` class and a `List`. – Dici Nov 07 '14 at 23:53

0 Answers0