# adding random numbers and giving a correct or incorrect response back to the user

• 07-23-2002
mshain
adding random numbers and giving a correct or incorrect response back to the user
/* Mike Shain
CIS 10 A
ONLINE
Project 1

This program is a Math Tutor program that will ouput different
random numbers using addition, multiplication, and subtraction.
It will also tell the user if the answer is correct and the
print out a report informing the user of how many incorrect and

****************** THIS LINE IS 70 CHARACTERS LONG **********
*/
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;

void doOneSet('+','-','*');
void RandomNum(int &FirstNum,int &SecondNum);
//void getNumbers(int &FirstNum,int &SecondNum);
//void getProbPerSet();

int main()
{
srand(time(0)); //creats random numbers
//getProbPerSet(); //get amount of problems per set
//doOneSet('-'); //The Subtraction set
//doOneSet('*'); //The Multiplication set
//printReports(); //Print the amount incorrect/correct

//return 0;
}

void doOneSet('+','-','*')
{
//getMaxNum
//doOneProblem

int FirstNum;
int SecondNum;
int pCount = 0; //counter for problems sets
char operand;

while (pCount < 5)
{
RandomNum(FirstNum,SecondNum);

//this is to check for a leading zero
//if (FirstNum < 10 || SecondNum < 10)
//{
cout << FirstNum << " + "
<< SecondNum
<< " = ";
//}
//else
//{
// cout << FirstNum
// << " + " << SecondNum
// << " = ";
//}

pCount ++; //Counts the loop until count = 5

getNumbers(char operand); //calls the getNumbers function
//then gets the operator
}
}

///*this will be renamed getOperand()
void getNumbers(char &operand)
{
//char operand;
switch (operand)
{
case '+' :
{
operand = FirstNum + SecondNum;
break;
}
case '-' :
{
//Subtraction
operand = FirstNum - SecondNum;
break;
}
case '*' :
{
//Multiply
operand = FirstNum * SecondNum;
}
}
}
*/
void RandomNum(int &FirstNum, int &SecondNum)
{
for (int i = 0 ; i < 100; i++)
{
//cout << setw(8) << rand() % 101;
FirstNum = rand() % 101;
SecondNum = rand() % 101;

if (i % 5 == 4)
{
//cout << endl;
}
}
}

void getProbPerSet()
{

}
• 07-24-2002
Ruski
If you want someone to at least try and answer your question, better use tags and to write neat code. That way people can at least read it from the beginning till the end :)
• 07-24-2002
nvoigt
void doOneSet('+','-','*');

huh ? If this is the declaration, use types as parameters, not constants.

Other than that... what exactly do you need help with ?
Nice program, but your question is what ?
• 07-24-2002
mshain
what the program is supposed to do is call the doOneSet() function 3 times and print out a set of problems based off of the operator (+,-,*).

So basically the first call would print out 5 addition problems and the 6 subtraction problems etc...

After all that is done as the user does each problem it shows them either correct or incorrect.