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

I got it!! after much trial and error. Sorry

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.