Files Question.java, Complexity.java, and MiniQuiz.java contain the classes in Listings 5.9-5.11 of the text (edition 3) or Listings 6.8-6.10 of the text (edition 4+). These classes demonstrate the use of the Complexity interface; class Question implements the interface, and class MiniQuiz creates two Question objects and uses them to give the user a short quiz.
Save these three files to your directory and study the code in MiniQuiz.java. Notice that after the Question objects are created, almost exactly the same code appears twice, once to ask and grade the first question, and again to ask and grade the second question. Another approach is to write a method askQuestion that takes a Question object and does all the work of asking the user the question, getting the user's response, and determining whether the response is correct. You could then simply call this method twice, once for q1 and once for q2. Modify the MiniQuiz class so that it has such an askQuestion method, and replace the code in main that asks and grades the questions with two calls to askQuestion. Some things to keep in mind:
private static void askQuestion(Question question)