#include <iostream>
using namespace std;
class Fraction {
public:
Fraction() : num(0), denom(1) {}
Fraction(int num, int denom) { setNum(num); setDenom(denom); }
int getNum() const { return num; }
int getDenom() const { return denom; }
void setNum(int num) { this->num = num; }
void setDenom(int denom) { if (denom) this->denom = denom; }
void checkGuess()
{
(if num ? denom = print())
cout<<"Thats is the correct answer";
else
cout<<"Wrong, Try again";
}
void reduce()
{
int g = gcd(num, denom);
num /= g;
denom /= g;
}
void print()
{
reduce();
cout << num << "/" << denom << "\n";
}
private:
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
int num, denom;
};
int main()
{
Fraction f1(9, 11), f2(10, 3);
Fraction f3(f1.getNum() * f2.getNum(), f1.getDenom() * f2.getDenom());
f1.print(); cout<<"*"; f2.print
cout<<"Please enter your guess"
cin>>num.checkGuess();
cin>>denom.checkGuess();
f3.print();
}
......that is what i have so far for my fraction program which i added the check guess in after i ran the other parts of the program. so i know that it doesnt run as is but minus the checkguess it run fine. I need to figure out how to print a different problem with random fraction generated when they get the previous problem correct. so for instance 1/3* 2/2 = 2/6 this is wrong the right answer is 1/3. after they type in the right answer a new problem shoudl appear for them to answer. any help please. thank you guys.