FractionClass:
public class FractionClass {
private int numerator;
private int denominator;
public FractionClass()
{
numerator = 1;
denominator = 2;
}
public FractionClass(int num, int den)
{
numerator = num;
if (den == 0)
den =1;
denominator = den;
}
public FractionClass add(FractionClass other)
{
return null;
}
public FractionClass subtract(FractionClass other)
{
return null;
}
public FractionClass multiply(FractionClass other)
{
int num = numerator * other.numerator;
int den = denominator * other.denominator;
return new FractionClass(num, den);
}
public FractionClass divide(FractionClass other)
{
int num = numerator * other.denominator;
int den = denominator * other.numerator;
return new FractionClass(num, den);
}
public void printFractionClass()
{
// Print values as a fraction
}
}
FractionClassTester:
public class FractionClassTester {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}