Hi there,
I am supposed to do a randomization of questions and the user answer them.
An example would be what does IE stands for:
the user must enters Internet Explorer. and it's correct.
However, in my programme, whenever the user enters "Internet Explorer" or any other string that has space, my program could not detect the correct answer. and it will loop 2 times depending on the String after the space the user entered. Example, Internet Explorer will loop 2 questions out.
Here is my source codes:
System.out.print("Ans: ");
answer = scn.next();
for (int num = 0; num < array.length; num++)
{
if (answer.toLowerCase().equals(array[num])
{
accPoints += 20;
System.out.println("Correct! You have " + accPoints + " points now!");
}
else
{
correct = false;
if (num ==0)
System.out.println("Incorrect! The answer is [" + array[num])+ "]");
}
}