My question pertains to a school assignment, and I want to emphasize that I am not looking for someone to just give me the answer. However, I am looking for direction so I can solve this problem.
I made a test program consisting of multiple choice and true/false questions. I placed this information in 2 .txt files. I'm organizing my code by class. I need to pull the information from the .txt file, output it to the screen, compare the user-input results with the test answers, and output a test score.
I know how to pull from a .txt file, but this has multiple choice and true-false questions that give string and char data. I considered creating arrays to store the questions and answers; however, I began to question whether there is a more efficient way to organize this data. It seems like I need way too many arrays, and perhaps 1 or 2 methods might suffice. I know how to calculate the test scores and do not need direction on that portion.
I'm developing this C++ code using the Microsoft Visual Studio IDE.
I've researched arrays, vectors, objects, classes, and many more topics that I thought may be related to this problem. I've read through my college textbook, listened to the lectures, watched YouTube videos, and consulted some programmers via Facebook. I've googled questions and read answers on various C++ topics and programming examples. The fact that I'm still confused leads me to believe perhaps I'm just not grasping these concepts like I should be.
Can anyone with more expertise point me in the right direction?
string question, answer;
string q, a;
int v;
int value;
cout << "====================================================\n";
cout << "== ==\n";
cout << "== WELCOME TO THE FBI ENTRANCE EXAM! ==\n";
cout << "== ==\n";
cout << "====================================================\n";
cout << endl;
cout << endl;
cout << "You will be asked a series of 11 questions consisting of both
True/False questions and multiple choice questions.\n";
cout << "Please answer each question to the best of your ability\n\n\n" <<
"Good luck!\n\n\n" << endl;
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Class and functions definitions for subclass QuestionTF of class Question
QuestionTF::QuestionTF(){}
QuestionTF::~QuestionTF(){}
QuestionTF::QuestionTF(const std::string& q, int v, const std::string& a)
: Question(q, v, a) {}
#include of a cpp file is generally a sign that you've misunderstood what #include does and how the compiler and linker work.
You have misunderstood the difference between creating an array, and then using it. string TestBankMC[71]; This CREATES an array of 71 strings.
string TestBankMC[0] = "some value"; This sets the value of ONE of those string cin >> answersMC[11];This is an attempt to store something in the 12th element of an array. Why do you try to store into an element that doesn't exist? Why do you try to do it over and over?
You need to stop, and go back and practice just creating an array, and then writing into the array. When you can do that, you are ready for more. You're trying to things without understanding the basics. Learn how to use an array first.
I removed the [#include .cpp] files. When I created my classes, I included the class declarations in a .h file, and the definitions in the .cpp file. Will my program still pull the class definitions?
Thank you for explaining the array. If I were to replace the index with i, would that sequentially store the user's answers in the array?
[// Test.cpp : This file contains the 'main' function. Program execution begins and ends there
cout << "====================================================\n";
cout << "== ==\n";
cout << "== WELCOME TO THE FBI ENTRANCE EXAM! ==\n";
cout << "== ==\n";
cout << "====================================================\n";
cout << endl;
cout << endl;
cout << "You will be asked a series of 11 questions consisting of both True/False questions and multiple choice questions.\n";
cout << "Please answer each question to the best of your ability\n\n\n" << "Good luck!\n\n\n" << endl;