Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

public class Question { private String text; private String answer; public Quest

ID: 3572524 • Letter: P

Question

public class Question
{
   private String text;
   private String answer;
  
   public Question()
   {
       text="";
       answer="";
   }
  
   public void setText(String questionText)
   {
       text=questionText;
   }
  
   public void setAnswer(String correctResponse)
   {
       answer=correctResponse;
   }
  
   public boolean checkAnswer(String response)
   {
       return response.replaceAll("\s+","").toLowerCase().equals(answer.replaceAll("\s+","").toLowerCase()));
   }
  
   public void display()
   {
       System.out.println(text);
   }

}

Add to this code, I want add a class NumericQuestion to the question hierarchy. (as a result there are two questions.)

If the response and the expected answer differ by no more than 0.01, then accept the response as correct.(using Integer.parseDouble)

And add a class choiceQuestion in order to display two questions.

Explanation / Answer

Please find the required program along with its output. Please see the comments against each line to understand the step.

-------------------------------------------------

OUTPUT:

Question 1: true
Question 2: false