예제 #1
0
  public void testPmt() {
    double f, r, y, p, x;
    int n;
    boolean t;

    r = 0;
    n = 3;
    p = 2;
    f = 7;
    t = true;
    y = Vba.pmt(r, n, p, f, t);
    x = -3;
    assertEquals(x, y);

    // cross check with pv
    r = 1;
    n = 10;
    p = -109.66796875;
    f = 10000;
    t = false;
    y = Vba.pmt(r, n, p, f, t);
    x = 100;
    assertEquals(x, y);

    r = 1;
    n = 10;
    p = -209.5703125;
    f = 10000;
    t = true;
    y = Vba.pmt(r, n, p, f, t);
    x = 100;
    assertEquals(x, y);

    // cross check with fv
    r = 2;
    n = 12;
    f = -6409178400d;
    p = 12000;
    t = false;
    y = Vba.pmt(r, n, p, f, t);
    x = 120;
    assertEquals(x, y);

    r = 2;
    n = 12;
    f = -6472951200d;
    p = 12000;
    t = true;
    y = Vba.pmt(r, n, p, f, t);
    x = 120;
    assertEquals(x, y);
  }
예제 #2
0
  public void testPPmt() {
    assertEquals(-607.9248252633897, Vba.pPmt(0.10, 1, 30, 100000, 0, false));
    assertEquals(-8422.451500705567, Vba.pPmt(0.10, 15, 30, 100000, 0, false));
    assertEquals(-10547.13234273705, Vba.pPmt(0.10, 30, 30, 100000, 0, false));

    // verify that pmt, ipmt, and ppmt add up
    double pmt = Vba.pmt(0.10, 30, 100000, 0, false);
    double ipmt = Vba.iPmt(0.10, 15, 30, 100000, 0, false);
    double ppmt = Vba.pPmt(0.10, 15, 30, 100000, 0, false);
    assertTrue(Math.abs(pmt - (ipmt + ppmt)) < 0.0000001);
  }