C++ Programing Fraction Class

I am having a hard time with this homework
The specifications for the assignment are listed below:

Modify the Fraction class so that the Fraction objects created using the class can store a mixed number rather than just a simple fraction. In order to do this, you will need add a whole number instance variable to the class.
Modify the reduce method of the Fraction class so that it can reduce a mixed number rather than just a simple fraction.
Rewrite the method main found in the project so that it can handle modified Fraction objects (mixed number fractions) in the same way that it currently handles simple fractions. Your main method should look similar to the example main method shown below.
An executable example of the completed application is available at the link Homework #3 Example.exe.

You may use a main method such as the one listed below to test your project if you choose to do so.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework03Project
{
class Program
{
static void Main(string[] args)
{
Fraction[] fractions = new Fraction[4];
int i;

fractions[0] = new Fraction(3, 48, 36);
fractions[1] = new Fraction(1, 34, 76);
fractions[2] = new Fraction(2, 16, 12);
fractions[3] = new Fraction(5, 72, 30);

for (i = 0; i < fractions.Length; i++)
{
Console.Write(fractions[i].ToString() + " reduced is ");
fractions[i].reduce();
Console.WriteLine(fractions[i]);
}
Console.Read();
}
}
}

---AND THIS IS THE CODE I HAVE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Homework03Project
{
class Fraction
{
private int wholenumber;
private int numerator;
private int denominator;

public Fraction(int wholenumber, int numerator, int denominator)
{
WholeNumber = wholenumber;
Numerator = numerator;
Denominator = denominator;
}

public int WholeNumber
{
get
{
return wholenumber;
}

set
{
wholenumber = value;
}
}
public int Numerator
{
get
{
return numerator;
}

set
{
numerator = value;
}
}

public int Denominator
{
get
{
return denominator;
}
set
{
if (value != 0)
{
denominator = value;
}
else
{
Console.WriteLine("Denominator cannot be zero. Denominator set to one.");
denominator = 1;
}
}
}
public void reduce()
{
int i, gcf;

gcf = 1;
i = 2;

while (i <= wholenumber && i <= numerator && i <= denominator)
{
if (wholenumber % i == 0 && numerator % i == 0 && denominator % i == 0)
{
gcf = i;
}
i++;
}
wholenumber = wholenumber / gcf;
numerator = numerator / gcf;
denominator = denominator / gcf;
}

public override string ToString()
{
return wholenumber + numerator + "/" + denominator;
}
}
}
What is your problem ?
Registered users can post here. Sign in or register to post.