Arrays not counting correctly
- by Nick Gibson
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