Great!
(If you just start typing the next post instead of hitting "reply", you don't get the entire previous post in your post.)
There are quite a few things you can do now.
First of all, I would suggest you reformat your code. Currently, some lines start at the left margin, while the line below is indented by some amount. Try to bring a system into that.
Many people indent lines in multiple of 4. You start at the left margin. Each time you start a new block, the next line indents 4 more spaces. Each time you end a block, the next line decreases 4 spaces indent.
The result is that most lines start vertically at the same offset, unless you start or end new blocks (often also indicated with { and }, but not always).
Similarly, decide how to write each type of name. As you can see, Java itself uses camelcase (lower case name, with uppercase letter for a new word), like "ArrayList" for classes. If you follow that idea, your "quiz" class should be named "Quiz" instead. You currently use names like "Alternatives_C" for a variable. As you can see, it looks very similar to a Java class name. If you use lowercase and underscore characters only, like "alternatives_c", it becomes more clear that it's a variable rather than a class name.
It may seem silly to you to spend time on this, and at the current stage, you are right. The reason why I bring it up (and also why everybody does this) is to increase clarity. We are very visually oriented, so if you write code that contains visual clues what things are, you get a lot more information just by glancing over the code, without even carefully studying it. This enhanced clarity gives more room to focus on the problem you are trying to solve, and allows you to work faster with less errors.
For example, using the above convention, I can see that 'Quiz' is a class, and 'quiz' is a variable at one glance at any point in the code.
If you learn yourself to use a convention like the above from the start, it becomes a habit, something you do without it taking extra time or effort. You shift one gear up in productivity without cost other than picking the right case convention for naming things.
Secondly, if you look at the information of a single quiz question, you will notice it is all scattered through the program. For example question a:
ArrayList<String> Alternatives_A = new ArrayList<String>();
Alternatives_A.add("A, Toronto");
Alternatives_A.add("B, Otawa");
Alternatives_A.add("C, vancoover");
String Question_A = "What is the capital of canada?";
if (in.equalsIgnoreCase("b")) {
Wouldn't it be nice if you could keep this data all together? Well, you can, with a new class QuizQuestion.java:
import java.util.ArrayList;
public class QuizQuestion {
/** The question to ask. */
public String question;
/** Possible answers. */
public ArrayList<String> answers = new ArrayList<String>();
/** The correct answer. */
public String good_answer;
/**
* Append another answer to the list of answers.
*
* @param answer New answer to add.
*/
public void addAnswer(String answer) {
answers.add(answer);
}
}
(have a look at how I format the code, how does that look to you?)
Ignore the "addAnswer" method for now, I'll come to that later. So here is a new class, and it has a 'question', a 'answers' array, and a 'good_answer'. All the things you have scattered in your program now. (No shame in that, I often also start trying a random piece of code, seeing how things work, before deciding how to organize things.)
In your main program, instead of making all the various variables, you now fill a QuizQuestion:
QuizQuestion question_a = new QuizQuestion();
question_a.question = "What is the capital of canada?";
question_a.answers.add("A, Toronto");
question_a.answers.add("B, Otawa");
question_a.answers.add("C, vancoover");
question_a.good_answer = "b";
and then you can use that information as follows:
System.out.println(question_a.question); // Print the question
for (String answer: question_a.answers) {
System.out.println(answer); // Print each answer (I don't think your solution actually did the right thing?)
}
in = user_input.nextLine();
if (in.equalsIgnoreCase(question_a.good_answer)) { // Compare the answer with the good_answer
System.out.print(Answer_Right);
} else {
System.out.println(Answer_Wrong);
}
When filling the answers, I didn't like ".answers.add" very much, it's too much detail. Instead, I wanted the QuizQuestion itself to handle that.
For this reason I wrote the "addAnswer". It takes a new answer, and then adds it to the answers list, just like "question_a.answers.add()" does. However, now I can write
QuizQuestion question_b = new QuizQuestion();
question_b.question = "What is 5^3?";
question_b.addAnswer("A, 125");
question_b.addAnswer("b, 15");
question_b.addAnswer("C, 100");
question_b.good_answer = "a";
Et voila, now I have "question.addAnswer", the question itself handles storing the answer now. It looks nicer now.
Try to make it work (keep a copy of your original code, so you can fallback to the previous version if you need to), perhaps there are other things you can change as well?