Hi, my name is Anita. I'm new to this forum and I'm here because I am utterly frustrated with this program that I have been working on for days. This program is supposed to ask the user a series of arithmetic problems and report on how the user performs. The way we are supposed to go about doing this is broken into phases.(I will put exactly what the assignment says at the end) Anyway, I've got two major problems right now. I got up to phase III, and then could NOT figure out how to change the parameters of my doOneSet function to do addition, subtraction and multiplication. My second problem is that up until that point my program worked when I used the g++ compiler on the Mac computers at school. But when I tried to compile the same exact .cpp file using DevC++ at home, it's giving me weird long numbers. The problem with this assignment is how she wants it done.(see end of post)
//***************************************************************************
//This program asks a series of arithmetic problems
//and reports the user's performance
//***************************************************************************
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<ctime>
using namespace std;
void doOneSet();
void doOneProblem();
void generateOperands(int &num1, int &num2);
void calcCorrectAnswer(int &result, int &userNum1);
void checkAnswer(int result, int userNum1);
int main()
{
srand(time(0));
doOneSet();
system("pause");
return 0;
}
//***************************************************************************
void doOneSet()
{
doOneProblem();
doOneProblem();
doOneProblem();
doOneProblem();
doOneProblem();
}
//***************************************************************************
void doOneProblem()
{
int num1, num2, result, userNum1;
generateOperands(num1, num2);
calcCorrectAnswer(result, userNum1);
checkAnswer(result, userNum1);
}
//***************************************************************************
void generateOperands(int &num1, int &num2)
{
num1=rand()%101;
num2=rand()%101;
}
//***************************************************************************
void calcCorrectAnswer(int &result, int &userNum1)
{
int num1, num2;
cout<<num1<<"+"<<num2<<"="; //To make arithmetic problem
cin>>userNum1;
result=num1+num2;
}
//**************************************************************************
void checkAnswer(int result, int userNum1)
{
if(userNum1==result)
{
cout<<"correct"<<endl;
}
else
{
cout<<"incorrect"<<endl;
}
}
Here is a link to my assignment. It's a .pdf file so I couldn't just copy and paste it here.
http://docs.google.com/fileview?id=0B05IOh-iexZwYTY0NWRmNzMtOGYyZi00NTA4LWE4YTgtYzNkN2E5M2ZmMGY5&hl=en
Thanks for any help!