Since this is homework, I am not asking for a solution. I am just asking for a bit of guidance. Whenever I am trying to function call, it for some reason loops around both MathMenu() and diff(). I can't seem to properly stack the multiple functions and have them reference each other correctly. Any tips or suggestions on where I can go from here? Or hint at what am I not seeing?
#include <ctime>
#include <iostream>
#include <iomanip>
#include <cstdlib>
usingnamespace std;
int MathMenu(int &);
int diff(int &);
int add(int &);
int app(int &);
int main() {
int a=0;
int b=0;
int c=0;
for (int i = 0; i == a; i++) {
diff(a);
for (int j = 0; j == b; j++) {
add(b);
for (int k = 0; k == c; k++) {
app(c);
}
}
}
}
int MathMenu(int & choice) {
cout << "Main Menu" << endl
<< "__________" << endl
<< "1.) Addition Problems" << endl
<< "2.) Subtraction Problems" << endl
<< "3.) Multiplication Problems" << endl
<< "4.) Division Problems" << endl;
cin >> choice;
while (choice < 1 || choice >5)
{
cout << "Main Menu" << endl
<< "__________" << endl
<< "1.) Addition Problems" << endl
<< "2.) Subtraction Problems" << endl
<< "3.) Multiplication Problems" << endl
<< "4.) Division Problems" << endl;
cin >> choice;
return choice;
}
return choice;
}
int diff(int & difficulty) {
int choice2 = MathMenu(choice2);
if (choice2 == 1) {
cout << "Enter the difficulty level. Difficulty will increase with higher levels." << endl
<< "Enter Difficulty: ";
cin >> difficulty;
while (difficulty < 1)
{
cout << "Error. Difficulty must be greater then 0.Enter the difficulty level. Difficulty will increase with higher levels." << endl
<< "Enter Difficulty: ";
cin >> difficulty;
}
int add(int &);
}
elseif (choice2 == 2) {
cout << "Enter the difficulty level. Difficulty will increase with higher levels." << endl
<< "Enter Difficulty: ";
cin >> difficulty;
while (difficulty < 1)
{
cout << "Error. Difficulty must be greater then 0.Enter the difficulty level. Difficulty will increase with higher levels." << endl
<< "Enter Difficulty: ";
cin >> difficulty;
}
}
elseif (choice2 == 3) {
cout << "Enter the difficulty level. Difficulty will increase with higher levels." << endl
<< "Enter Difficulty: ";
cin >> difficulty;
while (difficulty < 1)
{
cout << "Error. Difficulty must be greater then 0.Enter the difficulty level. Difficulty will increase with higher levels." << endl
<< "Enter Difficulty: ";
cin >> difficulty;
}
}
elseif (choice2 == 4) {
cout << "Enter the difficulty level. Difficulty will increase with higher levels." << endl
<< "Enter Difficulty: ";
cin >> difficulty;
while (difficulty < 1)
{
cout << "Error. Difficulty must be greater then 0.Enter the difficulty level. Difficulty will increase with higher levels." << endl
<< "Enter Difficulty: ";
cin >> difficulty;
}
}
return difficulty;
}
int add(int & modifier)
{
constint min = 0;
constint max = 9;
int seed = static_cast <int> (time(0));
srand(seed);
int level = diff(level);
int num1 = seed % 10;
int num2 = seed % 10;
srand(num1);
srand(num2);
int ans;
int cans = num1 + num2;
cout << "What is " << num1 << " + " << num2 << "? ";
cin >> ans;
modifier = rand() % 4;
srand(modifier);
return modifier;
}
int app(int & mod) {
mod = add(mod);
if (mod == 1)
cout << "Very Good!";
elseif (mod == 2)
cout << "Excellent!";
elseif (mod == 3)
cout << "Nice work!";
elseif (mod == 4)
cout << "Keep up the good work!";
system("Pause");
return 0;
}
Main Menu
__________
1.) Addition Problems
2.) Subtraction Problems
3.) Multiplication Problems
4.) Division Problems
1
Enter the difficulty level. Difficulty will increase with higher levels.
Enter Difficulty: 1
Main Menu
__________
1.) Addition Problems
2.) Subtraction Problems
3.) Multiplication Problems
4.) Division Problems
1
Enter the difficulty level. Difficulty will increase with higher levels.
Enter Difficulty: 1
What is 7 + 7?