0

I am trying to create a rational numbers program from scratch (I'm a brand new student basically), and I have all my inputs working right now. My problem lies within my showFraction() function, but I can't figure out how to fix it. It should output the inputs from the user and appear as a fraction, but what's coming out is a large negative number (basically junk).

```
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
class Rational
{
public:
void setNumerator1(int);
void setDenominator1(int);
void setNumerator2(int);
void setDenominator2(int);
void showFraction1(int&,int&);
private:
int Numerator1;
int Denominator1;
};
void main()
{
Rational MyNumerator1, MyDenominator1, MyNumerator2, MyDenominator2;
int Numerator1, Denominator1, Numerator2, Denominator2;
Numerator1 = 0;
Numerator2 = 0;
Denominator1 = 0;
Denominator2 = 0;
MyNumerator1.setNumerator1(Numerator1);
MyDenominator1.setDenominator1(Denominator1);
MyNumerator2.setNumerator2(Numerator2);
MyDenominator2.setDenominator2(Denominator2);
MyNumerator1.showFraction1(Numerator1,Denominator1);
}
void Rational::setNumerator1(int Numerator1)
{
cout << "Please Enter First Numerator: ";
cin >> Numerator1;
cout << endl;
}
void Rational::setDenominator1(int Denominator1)
{
cout << "Please Enter First Denominator: ";
cin >> Denominator1;
cout << endl;
}
void Rational::setNumerator2(int Numerator2)
{
cout << "Please Enter First Denominator: ";
cin >> Numerator2;
cout << endl;
}
void Rational::setDenominator2(int Denominator2)
{
cout << "Please Enter First Denominator: ";
cin >> Denominator2;
cout << endl;
}
void Rational::showFraction1(int&,int&)
{
cout << "First Fraction is: " << Numerator1 << "/" << Denominator1 << endl;
}
```

Here is the output that I'm getting:

```
Please Enter First Numerator: 1
Please Enter First Denominator: 4
Please Enter First Denominator: 5
Please Enter First Denominator: 2
First Fraction is: -858993460/-858993460
Press any key to continue . . .
```

*Edited 6 Years Ago by PDB1982*: n/a