473,394 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Please help with Math.pow

4
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...
Expand|Select|Wrap|Line Numbers
  1. import java.util.Scanner;
  2.  
  3. public class problem2 {
  4. public static void main(String[]args)
  5. {
  6. double interestRate;
  7. double years;
  8. double mortgage;
  9. double monthlyPay;
  10. double mIR;
  11. double nOY;
  12.  
  13. Scanner scan = new Scanner(System.in);
  14. System.out.println("Enter the interst rate.");
  15. interestRate=scan.nextDouble();
  16. System.out.println("Enter the duration of the loan in years.");
  17. years=scan.nextDouble();
  18. System.out.println("Enter the amount of the mortgage.");
  19. mortgage=scan.nextDouble();
  20.  
  21. mIR=interestRate/12;
  22. nOY= 12*years;
  23.  
  24. monthlyPay = Math.pow((mIR*mortgage)/ (1-(1/(1+mIR))),nOY);
  25. System.out.println(monthlyPay);
  26. }
  27. }
Feb 5 '09 #1
1 2375
bvav22
4
ROFL never mind.....




i was raising the WHOLE formula with Math.pow and not the part i needed to.... please disregard my question....
Feb 5 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Brian Wilson | last post by:
Could someone help me with how to center or pocission this document to the center of the page? <body onload="ImageBook()"> <script type="text/javascript"> // 7 variables to control behavior...
5
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action...
36
by: Cap'n Ahab | last post by:
I have used VB3 - VB6, so learning all this OO stuff is reasonably new to me (although I looked at Java a few years ago). Anyway, I thought I would write a small class to begin with, with a...
2
by: Webdiyer | last post by:
Hi, We all know that the return value of Math.Log(8,2) is 3,but how about (int)Math.Log(8,2)? On my machine,the return value of (int)Math.Log(8,2) is strange enough! it's not 3 but 2 ! I've...
5
by: karmalax | last post by:
public static string Somme(string T) { string text1 = ""; double num5 = Strings.Len(T) + 1; int num3 = 7;
11
by: Amy | last post by:
Hello, I need to make this select an array item randomly instead of in order. Anyone know how? Thank you very much. Amy <BODY onload="changelink();"><a href="#" id="url"></a> var arr = ,, ,...
3
by: blogger | last post by:
i try use this script but keep getting Char: 6 Error: Expected ';' What can i do? <SCRIPT type="text/javascript"> /*Script distributed by Hypergurl.com Visit ...
1
by: theflyingminstrel | last post by:
Hi, I’m having some trouble with a Javascript code, and I was wondering if anyone can help: I am trying to build a price estimator that has multiple fields. I would like the first two fields to...
4
by: neptundancer | last post by:
Hi, to extend my skills, I am learning python. I have written small program which computes math expression like "1+2*sin(y^10)/cos(x*y)" and similar, so far only + - * / ^ sin con tan sqrt are...
2
by: alireza6485 | last post by:
Hi, Could you please rewrite the program for me?I tried my best and the program still does not do what it has to do. I have to write a code that generates random speed and distance .it ask the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.