### Question:
Quantities { public static QuantitativeAmount subtract( QuantitativeAmount x, BigDecimal amount ){ return of( x.getAmount().subtract(amount), x.getUnitName()); }  static QuantitativeAmount of( BigDecimal amount, Unit unit ); static QuantitativeAmount of( BigDecimal amount, UnitName unitName ); static QuantitativeAmount of( BigDecimal amount, String unitName ); static QuantitativeAmount convert( QuantitativeAmount quantity, UnitName unitName ); static QuantitativeAmount add( QuantitativeAmount x, BigDecimal amount ); static QuantitativeAmount add( QuantitativeAmount x, QuantitativeAmount y ); static QuantitativeAmount add( QuantitativeAmount x, QuantitativeAmount y, UnitName unitName ); static QuantitativeAmount subtract( QuantitativeAmount x, BigDecimal amount ); static QuantitativeAmount subtract( QuantitativeAmount x, QuantitativeAmount y ); static QuantitativeAmount subtract( QuantitativeAmount x, QuantitativeAmount y, UnitName unitName ); static QuantitativeAmount multiply( QuantitativeAmount x, BigDecimal amount ); static QuantitativeAmount multiply( QuantitativeAmount x, QuantitativeAmount y ); static QuantitativeAmount multiply( QuantitativeAmount x, QuantitativeAmount y, UnitName unitName ); static QuantitativeAmount divide( QuantitativeAmount base, BigDecimal amount ); static QuantitativeAmount divide( QuantitativeAmount x, QuantitativeAmount y ); static QuantitativeAmount divide( QuantitativeAmount x, QuantitativeAmount y, UnitName unitName );  }### Answer:
@Test public void testsubtract1() throws UnitException { System.out.println("subtract1"); QuantitativeAmount q = new QuantitativeAmount(BigDecimal.TEN, MassUnitSet.GRAM); QuantitativeAmount expResult = new QuantitativeAmount( BigDecimal.ZERO, MassUnitSet.GRAM); QuantitativeAmount result = Quantities.subtract(q, BigDecimal.TEN); assertEquals(expResult, result); }
@Test public void testsubtract2() throws UnitException { System.out.println("subtract2"); QuantitativeAmount q1 = new QuantitativeAmount(BigDecimal.TEN, MassUnitSet.GRAM); QuantitativeAmount q2 = new QuantitativeAmount(BigDecimal.TEN, MassUnitSet.GRAM); QuantitativeAmount expResult = new QuantitativeAmount( BigDecimal.ZERO, MassUnitSet.GRAM); QuantitativeAmount result = Quantities.subtract( q1, q2); assertEquals(expResult, result); }
@Test public void testsubtract3() throws UnitException { System.out.println("subtract3"); QuantitativeAmount q1 = new QuantitativeAmount(BigDecimal.TEN, MassUnitSet.GRAM); QuantitativeAmount q2 = new QuantitativeAmount(new BigDecimal(100), MassUnitSet.DECIGRAM); QuantitativeAmount expResult = new QuantitativeAmount( BigDecimal.ZERO, MassUnitSet.GRAM); QuantitativeAmount result = Quantities.subtract( q1, q2); assertEquals(expResult, result); }
@Test public void testsubtract4() throws UnitException { System.out.println("add4"); QuantitativeAmount q1 = new QuantitativeAmount(BigDecimal.TEN, MassUnitSet.GRAM); QuantitativeAmount q2 = new QuantitativeAmount(new BigDecimal(100), MassUnitSet.DECIGRAM); QuantitativeAmount expResult = new QuantitativeAmount( BigDecimal.ZERO, MassUnitSet.CENTIGRAM); QuantitativeAmount result = Quantities.subtract(q1, q2, MassUnitSet.CENTIGRAM); assertEquals(expResult, result); }