0

So I need to write test cases for a problem with multiplying, dividing, adding, & subtracting fractions but I just can't quite seem to get it correct that it works.

Here is part of the test file

//Multiply
		if (f1.multiply(f2) == (-2/15))
		{
			System.out.println("test multiply: passed");
		}
		else
		{
			System.out.println("test multiply: FAILED");
		}

**I am just having difficulties writing the first line so it works.
If I type:

System.out.println(f1.multiply(f2));

My answer is -2/15 so it is performing the procedure correctly.
Since f1 = 1/3 and f2 = (-2/5)

If I do .equals("-2/5") it compiles but then says it failed

Here is the other document if you need it, idk

//Multiply
	public Fraction multiply(Fraction otherFraction)
	{
		int NumeratorMultiply = 0;
		int DenominatorMultiply = 0;

		NumeratorMultiply = numerator * otherFraction.getNumerator();
		DenominatorMultiply = denominator * otherFraction.getDenominator();

		return new Fraction(NumeratorMultiply, DenominatorMultiply);
		 
	}

Thanks

Edited by kchadek: n/a

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by kchadek
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.