Arrays not counting correctly

Posted by Nick Gibson on Stack Overflow See other posts from Stack Overflow or by Nick Gibson
Published on 2010-06-02T18:44:26Z Indexed on 2010/06/02 19:03 UTC
Read the original article Hit count: 199

Filed under:
|

I know I was just asking a question earlier facepalm

This is in Java coding by the way.

Well after everyones VERY VERY helpful advice (thank you guys alot)

I managed to get over half of the program running how I wanted.

Everything is pointing in the arrays where I want them to go. Now I just need to access the arrays so that It prints the correct information randomly.

This is the current code that im using:

http://pastebin.org/301483

The specific code giving me problems is this:

long aa; int abc;

for (int i = 0; i < x; i++)
{
 aa = Math.round(Math.random()*10);

 String str = Long.toString(aa);
 abc = Integer.parseInt(str);

 String[] userAnswer = new String[x];

 if(abc > x)
 {
  JOptionPane.showMessageDialog(null,"Number is too high. \nNumber Generator will reset.");
  break;
 }

 userAnswer[i] = JOptionPane.showInputDialog(null,"Question "+quesNum+"\n"+questions[abc]+"\n\nA: "+a[abc]+"\nB: "+b[abc]+"\nC: "+c[abc]+"\nD: "+d[abc]);

 answer = userAnswer[i].compareTo(answers[i]);

 if(answer == 0)
 {
  JOptionPane.showMessageDialog(null,"Correct. \nThe Correct Answer is "+answers[abc]+""+i);
 }
 else
 {
  JOptionPane.showMessageDialog(null,"Wrong. \n The Correct Answer is "+answers[abc]+""+i);
 }//else

© Stack Overflow or respective owner

Related posts about java

Related posts about arrays