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

This is a C++question. Write a class called Question that represents a multiple

ID: 3674768 • Letter: T

Question

This is a C++question.

Write a class called Question that represents a multiple choice question for an exam. The class should have the following private member fields:

1. A trivia question

2. A string array of length 4 [this can be statically allocated] for the possible answers (exactly one of the answers must be correct)

3. The number of the correct answer (1, 2, 3, 4)

4. The number of points that the question is worth (as a double)

The class should have appropriate constructor(s) and member function(s), including one with the following prototype:

   int makeSelection(int choice)

This method should return the points for the question if the choice matches the correct answer and 0 otherwise.

Explanation / Answer

Hi, I have added basic functionality in Question class. You can other according to your need

class Question
{
   string question;
   string options[4];
   int point;
   int number_of_correct_ans;
  
public:
       Question(){
          
           }
       Question(string q, string opts[], int p, int n){
           question = q;
           options[0] = opts[0];
           options[1] = opts[1];
           options[2] = opts[2];
           options[3] = opts[3];
           point =p;
           number_of_correct_ans = n;
           }
       int makeSelection(int n){
           if(n==number_of_correct_ans)
               return point;
           return 0;
           }              
   };

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote