Calculations coming out to 0.0?
- by Nick Gibson
A simple percentage calculation. It wont return a value except 0.0 and I think once or twice it returned 100.0%. Other than that it won't do a thing. I have tried playing with the code in several different ways and it just wont work.
for (int loop = 1; loop < loopCount; loop++)
{
aa = r.nextInt(10+1);
abc = (int) aa;
String[] userAnswer = new String[x];
int totalQues = (correctAnswer + wrongAnswer), actualQues = (totalQues - 1);
if(abc < x)
{
userAnswer[abc] = JOptionPane.showInputDialog(null,"Question "+quesNum+"\n\n"+questions[abc]+"\n\nA: "+a[abc]+"\nB: "+b[abc]+"\nC: "+c[abc]+"\nD: "+d[abc]+"\nCorrect Answers: "+correctAnswer+"\nWrong Answers: "+wrongAnswer+"\nTotal Questions: "+totalQues);
if(userAnswer[abc].equals(answers[abc]))
{
correctAnswer++;
}
else
{
wrongAnswer++;
}//else
if(actualQues == x);
{
score = (correctAnswer / actualQues) * 100;
JOptionPane.showMessageDialog(null,"The test is finished.");
JOptionPane.showMessageDialog(null,"You scored "+score+"%");
}//if
}//if
}//for