Create A MathProblem class that contains four Fraction objects: the first Fraction operand in a problem, the second Fraction operand in a problem, the user's Fraction answer to the problem, and the correct Fraction answer. The MathProblem[ class also contains a character field that stores an operator. (for now, assume the operator will be either + or *) and contains a bool field named isAnswerCorrect, indicating whether the user correctly answered the problem. Include a function named setProblem() that sets a MathProblem's values with arguments that include two Fraction operands and an operation. This function calculates and stores the correct answer, assigns 0 to the user's answer, and sets isAnswerCorrect to false. Include a displaProblem() function that displays the math problem as a question, and an askUserForAnswer function that accepts the user's answer from the keyboard and assigns an appropriate value to isAnswerCorrect Include any other MathProblem functions you feel are useful and appropiate. Write a main() function that declares five MathProblem objects you can use to test a student's fraction arithmetic skills. Assign vlaues to the MathProblems. Display the problems and accept the answer. When the five problems are completed, display each of the problems, along with the student's answer, the correct answer, and a message indicating whether the student is right or wrong. Finally, show the student a score indicating the percentage of problems answered correctly.
The Fraction class is based off another program and is already implemented into my current code but it needs some polishing up, as I need to figure out how to get it to output in fraction notation. Right now it is outputting as a decimal.
Here is my current code:
#include "stdafx.h"
#include <iostream>
class Fraction
{
private:
double num;
double den;
int whole;
double frac;
public:
Fraction(double, double);
Fraction(int, double, double);
};
class MathProblem
{
private:
Fraction frac1;
Fraction frac2;
Fraction userAnswer;
Fraction correctAnswer;
char op;
bool corr;
public:
void setProblem(Fraction, Fraction, char);
void displayProblem();
void askUserForAnswer();
};
void MathProblem::setProblem(Fraction frac1, Fraction frac2, char op)
{
}
Fraction::Fraction(double num, double den)
{
if (den <= 0)
den = 1;
frac = num / den;
}
Fraction::Fraction(int whole, double num, double den)
{
if (den <= 0)
den = 1;
frac = (num / den) + whole;
}
int main()
{
MathProblem prob1;
MathProblem prob2;
MathProblem prob3;
MathProblem prob4;
MathProblem prob5;
Fraction frac1;
Fraction frac2;
char op;
std::cin.ignore();
std::cin.get();
}
I appreciate everyones help on this, I think its pretty rough for me. :sleep:
Edited by xXAlphaXx, 25 April 2010 - 08:48 AM.
Typos.


Sign In
Create Account


Back to top









