1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
|
#include "Quiz.h"
using namespace std;
// function prototypes
void menu();
void selection();
void studySec1();
void studySec2();
void studySec2one();
void studySec2two();
void studySec2three();
void studySec2four();
void studySec3();
void lec1();
void lec2();
int main()
{
string name;
int choice; // for section selection
//call main menu
menu();
cout << "Please enter your first name ";
cin >> name;
cout << "Thank you " << name << endl;
//call selection
selection();
cin >> choice;
if (choice == 1)
{
// call study section one
studySec1();
cout << "press 1 to continue or any other key to exit" << endl;
cin >> choice;
if (choice == 1)
{
// call study section two
studySec2();
cout << "Which loops would you like to learn about? " << endl;
cout << " while (1)\n do-while(2)\n for (3)\n or the if /else (4)" << endl;
cout << " or 5 to continue" << endl;
cin >> choice;
while (choice <= 5)
{
if (choice == 1)
{
studySec2one();
cout << "please make another selection" << endl;
cin >> choice;
}
else if (choice == 2)
{
studySec2two();
cout << "please make another selection" << endl;
cin >> choice;
}
else if (choice == 3)
{
studySec2three();
cout << "please make another selection" << endl;
cin >> choice;
}
else if (choice == 4)
{
studySec2four();
cout << "please make another selection" << endl;
cin >> choice;
}
else if (choice == 5)
{
studySec3();
cout << " Thank you for studying!";
break;
}
}
}
}
else if (choice == 2)
{
// this is the lectures section
// call lecture 1
lec1();
cout << "press 1 to continue or any other key to exit" << endl;
cin >> choice;
if (choice == 1) {
lec2();
cout << endl << endl;
cout << "Thank you for using the lecture section";
}
}
else if (choice == 3)
{
// this is the quiz section
cout << "Press enter to start...\n";
cin.get();
//Ask if user wants to start quiz.
string respond;
cout << "Are you ready to start the quiz, " << name << "? Yes/No.\n";
cin >> respond;
//If user says yes, the quiz will start.
if (respond == "Yes" || respond == "yes") {
cout << "\n";
cout << "Good luck!\n";
cout << "\n";
cout << "Press enter to continue.";
cin.get();
cin.ignore();
//Instances of the questions.
Question q1;
Question q2;
Question q3;
Question q4;
Question q5;
Question q6;
Question q7;
Question q8;
Question q9;
Question q10;
q1.setValues("1. What command prints something to the screen?",
"cin",
"cout",
"char",
"print",
'b',
10);
q2.setValues("2. Which of the following categories does C++ belong to?",
"Operating System",
"High-level programming language",
"low-level programming language",
"Compiler",
'b',
10);
q3.setValues("3. Which command is correctly written?",
"cout >>",
"cin <<",
"cout <>",
"cin >>",
'd',
10);
q4.setValues("4. What is this called, <iostream>?",
"directive",
"pre-processor directive",
"file",
"command",
'b',
10);
q5.setValues("5. What punctuation ends most lines of code?",
" . ",
" ; ",
" : ",
" ' ",
'b',
10);
q6.setValues("6. Which of the following is a correct comment?",
"*/ Comments */",
"** Comment **",
"/* Comment */",
"{ Comment }",
'c',
10);
q7.setValues("7. Which of the following is the boolean operator for logical-and?",
"&",
"|",
"&&",
"|&",
'c',
10);
q8.setValues("8. Which of the following shows the correct syntax for an if statement?",
"if expression",
"if {expression",
"if (expression)",
"expression if",
'c',
10);
q9.setValues("9. How many times is a do while loop guaranteed to loop?",
"1",
"0",
"Infinitely",
"Variable",
'a',
10);
q10.setValues("10. A subscipt is a(n) __________ .",
"element in an array",
"alternate name for an array",
"number that represents the highest value stored within an array",
"number that indicates the position of the particular item in an array",
'd',
10);
//call questions
q1.askQuestion();
q2.askQuestion();
q3.askQuestion();
q4.askQuestion();
q5.askQuestion();
q6.askQuestion();
q7.askQuestion();
q8.askQuestion();
q9.askQuestion();
q10.askQuestion();
cout << "your total is" << total << "out of 100";
cout << endl;
system("pause");
}
else {
cout << endl;
cout << "Goodbye!\n";
cin.ignore();
std::cin.get();
return 0;
}
}
else
cout << "you have entered an invalid selection" << endl;
return 0;
system("pause");
return 0;
}
|