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
|
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <cmath>
#include <stdlib.h>
#include <ctime>
// Prototype goes here //
using namespace std;
char userinf(ofstream&);
char Math_menu(ofstream &, int level);
int difficulty_menu(ofstream&);
void Multiply(int level, ofstream&);
void Add(int level, ofstream&);
void Subtract(int level, ofstream&);
void Divide(int level, ofstream&);
//double randomGen(int level);
int main()
{
ofstream outputFile;
outputFile.open("name.txt");
unsigned seed = time(NULL);
srand(seed);
userinf(outputFile);
int level = difficulty_menu(outputFile);
Math_menu(outputFile, level);
}
char userinf(ofstream &outputFile)
{
string firstName;
string lastName;
cout << "Please enter your first name " << endl;
cin >> firstName;
outputFile << firstName;
outputFile << lastName;
cout << "Please enter your last name " << endl;
cin >> lastName;
outputFile << firstName << lastName;
return 0;
}
int difficulty_menu(ofstream &outputFile)
{
int level;
int choice;
cout << "\t ---------------------------------------------------------" << endl;
cout << "\tDifficulty Menu" << endl;
cout << " ---------------------------------------------------------" << endl;
cout << "\tPlease choose your desired level of difficulty" << endl;
cout << "\t1. Beginner " << endl;
cout << "\t2. Intermediate " << endl;
cout << "\t3. Advanced " << endl;
cout << "\t4. Expert " << endl;
cout << "\t5. Mathmatician" << endl;
cout << "\t---------------------------------------------------------" << endl;
cout << "\tEnter your choice[1 2 3 4 5]:";
cin >> level;// paramater
switch (level)
{
case 1:
cout << "You haven Choosen level 1" << endl;
break;
case 2:
cout << "you have choosen level 2" << endl;
break;
case 3:
cout << "you have choosen level 3" << endl;
break;
case 4:
cout << "you have choosen level 4" << endl;
break;
case 5:
cout << "You have choosen level 5" << endl;
break;
default:
cout << " Please make a selection 1-5" << endl;
}
system("pause");
return level;
}
char Math_menu(ofstream &outputFile, int level)
{
{
bool test = true;
while (test = true)
{
int basic;
char input[100]; // array allows for more than on input.
system("cls");
cout << "ARITHMETIC PRACTICE PROGRAM" << endl;
cout << "Hello, and welcome to the Math Skills Practice Program.\n"
"This program allows you to practice your math skills.\n"
"Choose what you want to practice in the menu shown below." << endl;
cout << " ---------------------------------------------------------" << endl;
cout << " ARITHMETIC PRACTICE PROGRAM" << endl;
cout << " MAIN MENU" << endl;
cout << " ---------------------------------------------------------" << endl;
cout << " a.Addition" << endl;
cout << " b.Subtraction" << endl;
cout << " c.Multiplication" << endl;
cout << " d.Division" << endl;
cout << " q.Quit the program" << endl;
cout << " ---------------------------------------------------------" << endl;
cout << " Enter your choice[a b c d q]:";
cin >> input;
basic = input[0]; // [0] uses the first char of our 100 list, since we do not use char it is not a declaration of size//
cout << " your level is " << level;
switch (basic)
{
case 'a':
cout << "you have choosen addition" << endl;
Add(level, outputFile);
break;
case 'b':
cout << "you have choosen Subtraction" << endl;
Subtract(level, outputFile);
break;
case 'c':
cout << "you have choosen Multiplication" << endl;
Multiply(level, outputFile);
break;
case 'd':
cout << "you have choosen Division" << endl;
Divide(level, outputFile);
break;
case 'q':
test = false;
break;
}
system("pause");
}
return 0;
}
}
void Add(int level, ofstream &outputFile)
{
double number1;
double number2;
double realAnswer;
double rand_answer;
int multi_choice[4];
int position = rand() % 4;
if (level == 1) {
number1 = (rand() % 10 + 1);
number2 = (rand() % 10 + 1);
for (position = 0; position < 4; position++){
multi_choice[position] = (rand() % 10 + 1);
}
}
if (level == 2) {
number1 = (rand() % (99 - 10) + 10);
number2 = (rand() % (99 - 10) + 10);
for (position = 0; position < 4; position++){
multi_choice[position] = (rand() % (99 - 10) + 10);
}
}
if (level == 3) {
number1 = (rand() % (999 - 100) + 100);
number2 = (rand() % (999 + 100) + 100);
for (position = 0; position < 4; position++){
multi_choice[position] = (rand() % (999 + 100) + 100);
}
}
if (level == 4) {
number1 = (rand() % (9999 - 1000) + 1000);
number2 = (rand() % (9999 - 1000) + 1000);
for (position = 0; position < 4; position++){
multi_choice[position] = (rand() % (9999 - 1000) + 1000);
}
}
if (level == 5) {
number1 = (rand() % (99999 - 10000) + 10000);
number2 = (rand() % (99999 - 10000) + 10000);
for (position = 0; position < 4; position++){
multi_choice[position] = (rand() % (99999 - 10000) + 10000);
}
}
cout << " Please answer the following question: \n" << endl;
cout << " " << number1 << endl;
cout << "+" << number2 << "\n________" << endl;
char answer;
int loopCounter = 0;
realAnswer = number1 + number2;
for (; loopCounter < 3; loopCounter++){
int a_position = rand() % 5;
if (a_position != 4){
multi_choice[a_position] = realAnswer;
}
char letter_realAnswer = a_position + 97;
cout << "'a'" << multi_choice[0] << endl;
cout << "'b'" << multi_choice[1] << endl;
cout << "'c'" << multi_choice[2] << endl;
cout << "'d'" << multi_choice[3] << endl;
cout << "'e'" "None of the above" << endl;
cin >> answer;
if (answer == letter_realAnswer) {
cout << "congrats, thats right!" << endl;
break;
}
else {
cout << "Please try again" << endl;
}
}
}
|