for (int i = 0; i <= 30; i++)
{
UserAnswer= JOptionPane.showInputDialog(Questions[i]);
if (UserAnswer.equalsIgnoreCase(Answers[i]))
{
//do stuff
}
}
String a = "Hello";
String b = "Hello";
return a == b;
WallShadow wrote:good luck convincing the user to input the answers all in the proper order and spacing.
LoGiCaL__ wrote:WallShadow wrote:good luck convincing the user to input the answers all in the proper order and spacing.
I agree. Maybe it would be better to present the user with a multiple choice type of quiz instead of a accepting user input. You could then just test for the correct choice instead of comparing your answer array to the users input answers.
WallShadow wrote:Also, if you want to compare strings, don't use equals. use compareTo(), and if you are comparing strings, it is actually better to use compareToIgnoreCase() or to use toLowerCase() before you even compare them so that an answer of "eagle" will still match "Eagle".
dawodus wrote:1.how to make it so that the array would recieve uppercases and lowercases and maybe ever multiple answers as you can see with a few questions may have more than 1 answer.
Pattern pattern = Pattern.compile(Pattern.quote(","));
String [] data = pattern.split("testing, spaces! ! ! , !@#$%^&*()_+-=`~\\| ,, ,");
for(int i = 0; i < data.length; i++) {
System.out.println(i + " : '" + data[i] + "'");
}
0 : 'testing'
1 : ' spaces! ! ! '
2 : ' !@#$%^&*()_+-=`~\| '
3 : ''
4 : ' '
dawodus wrote:2. if randomization is possible to the array number inside[](i would only like to ask 10 questions of the 30 randomly)
dawodus wrote:3. we are not allowed to make it multiple choice unfortunetly it has to relay if the answer is specifically right or wrong
dawodus wrote:4. this method feels messy hence why i stopped half way is there not a better way maybe it could retrieve the questions from a file and compare it to answers from another file?
weekend hacker wrote:PS: is it obvious that while I'm on windows and don't have my spellchecker I can't write for shit?
weekend hacker wrote:I personaly dislike compareTo, ...
weekend hacker wrote:If only there was an equals that did unicode...
Users browsing this forum: No registered users and 0 guests