0

/*I am a noob and can not seem to be able to pass a random number to cout. I have tried everything amd am looking for a little guidance*/

```
#include <iostream>
#include <ctime>
using namespace std;
class Fraction
{
private:
int num; // Numerator
int den; // Denominator
public:
int num2;
int den2;
double setNumerator() {return num;} //sets numerator
double setDenominator() {return den;} //sets Denominator
double setNumerator2() {return num2;} //sets numerator 2
double setDenominator2() {return den2;} //sets Denominator 2
int Reduce(); //will reduce the fraction to lowest terms
void print(); //will print the fraction in the form: numerator / denominator
void Result(); //will multiply the fractions
Fraction(); // constructor
Fraction(int,int); // 2 Argument Constructor
};
Fraction::Fraction()
{
num=0;
den=1;
}
Fraction::Fraction(int n,int d)
{
num=n;
den=(d==0)? 1 :d;
}
double setNumerator (int num) //sets numerator 1
{
srand ( time(NULL) );
num = rand() % 9 + 1;
return num;
}
double setDenominator (int den) //sets denominator 1
{
srand ( time(NULL) );
den = rand() % 9 + 1;
return den;
}
double setNumerator2 (int num2) //sets numerator 2
{
srand ( time(NULL) );
num2 = rand() % 9 + 1;
return num2;
}
double setDenominator2 (int den2) //sets denominator 2
{
srand ( time(NULL) );
den2 = rand() % 9 + 1;
return den2;
}
//Fract2.setNumerator(rand() % 9 + 1);
//Fract2.setDenominator(rand() % 9 + 1);
//Result.setDenominator(Fract1.getDenominator() * Fract2.getDenominator());
void Result(int &num, int &den, int &num2, int &den2) //will multiply the results from the random numbers
{
int calcnum;
int calcden;
calcnum = num * num2;
calcden = den * den2;
}
int Reduce(int a, int b) //will reduce Result
{
int calcden = a;
int calcnum = b;
if(b == 0)
{
return a;
}
else
{
return Reduce(b, a % b);
}
}
void print(int &num, int &den) //will print out what the fraction is
{
cout << "The reduced and added fraction is " << num << "/" << den << endl;
}
int main() //the main
{
int num = 0, den = 0, num2 = 0, den2 = 0;
int calcnum = 0;
int calcden = 0;
int a = 0;
int b = 0;
int m = 0;
int n = 0;
cout << "What is " << num << "/" << den<< "*" << num2<< "/" <<den2<< "?"<<endl;
cout << "enter numerator / denominator" << " " << "Your answer must be in reduced form" << endl;
cin >> num >> den;
//Result(num, den, num2, den2);
Reduce(a, b);
print(num, den);
cout << endl;
return(0);
}
```