Please help with Math.pow

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bvav22
    New Member
    • Feb 2009
    • 4

    #1

    Please help with Math.pow

    I am trying to write a program that will calculate monthly payments based on information entered by the user. however, when i used math.pow it returns infinity. i know my formula is right i have tested it with a calculator 100 times now, i just dont get why its returning infinity.


    this is my code...
    [code=java]
    import java.util.Scann er;

    public class problem2 {
    public static void main(String[]args)
    {
    double interestRate;
    double years;
    double mortgage;
    double monthlyPay;
    double mIR;
    double nOY;

    Scanner scan = new Scanner(System. in);
    System.out.prin tln("Enter the interst rate.");
    interestRate=sc an.nextDouble() ;
    System.out.prin tln("Enter the duration of the loan in years.");
    years=scan.next Double();
    System.out.prin tln("Enter the amount of the mortgage.");
    mortgage=scan.n extDouble();

    mIR=interestRat e/12;
    nOY= 12*years;

    monthlyPay = Math.pow((mIR*m ortgage)/ (1-(1/(1+mIR))),nOY);
    System.out.prin tln(monthlyPay) ;
    }
    }[/code]
    Last edited by Nepomuk; Feb 5 '09, 11:59 AM. Reason: Please use [CODE] tags
  • bvav22
    New Member
    • Feb 2009
    • 4

    #2
    ROFL never mind.....




    i was raising the WHOLE formula with Math.pow and not the part i needed to.... please disregard my question....

    Comment

    Working...