Ok we have to make a 10 question quiz for my computer programming class this is what i have so far and im gettting so pissed off cuz it wont see if the answer they put in is right or not
Main file-
public class Quiz
{
private String question;
private String choiceA;
private String choiceB;
private String choiceC;
private String choiceD;
private String correctAnswer;
private String rightAnswer;
}
public static String getStr (String title) throws Exception
// Returns and input string.
{
char ch;
String str= "";
System.out.print("\t" + title + ": ");
do
{
ch = (char)System.in.read();
str += ch;
}
while ((int)ch !=13); // 13 is the first byte value of Enter key.
System.in.read(); // Second byte occupied by the Enter key.
return str;
}
}
thanks for any help
03-15-2005, 02:31 AM
sjalle
I haven't gone through all the code, but this one is strange...
And one more thing;
string comparison is done using the equals method, if you use the '==' operator
you are comparing pointer values, not string values.