Hi,
what I'm doing here is creating an application that prepares test questions. It can create multiple choice or essay. I've gotten most of it to work perfectly. I'm just experiencing one problem. For the multi choice class, in the readQuestion method I can enter how many choices I want the answer to have. This is the method:
public void readQuestion()
{
System.out.println("How many choices? ");
numChoices = scan.nextInt();
String[] options = new String[numChoices];
System.out.println("Enter the question: ");
question = scan.next();
for(int index = 0; index < options.length; index++)
{
System.out.println("Enter Choice " + (index + 1) + ": ");
options[index] = scan.next();
}
}
When I call this method in my driver program, the output is as follows:
Enter the number of questions:
1
Enter question type:
m
Question type is m
How many choices?
2
Enter the question:
what package is the scanner class from?
Enter Choice 1: Enter Choice 2:
The problem is that it doesn't allow me to enter 'choice 1' or 'choice 2'.
I can't seem to see where I'm going wrong..maybe a pair of fresh eyes would help?
Thanks in advance =)
what I'm doing here is creating an application that prepares test questions. It can create multiple choice or essay. I've gotten most of it to work perfectly. I'm just experiencing one problem. For the multi choice class, in the readQuestion method I can enter how many choices I want the answer to have. This is the method:
public void readQuestion()
{
System.out.println("How many choices? ");
numChoices = scan.nextInt();
String[] options = new String[numChoices];
System.out.println("Enter the question: ");
question = scan.next();
for(int index = 0; index < options.length; index++)
{
System.out.println("Enter Choice " + (index + 1) + ": ");
options[index] = scan.next();
}
}
When I call this method in my driver program, the output is as follows:
Enter the number of questions:
1
Enter question type:
m
Question type is m
How many choices?
2
Enter the question:
what package is the scanner class from?
Enter Choice 1: Enter Choice 2:
The problem is that it doesn't allow me to enter 'choice 1' or 'choice 2'.
I can't seem to see where I'm going wrong..maybe a pair of fresh eyes would help?
Thanks in advance =)