Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Math operators  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to java and trying to create a simple compound interest program. I used this code,


however, I keep reciving an error message under the pow, saying that the method pow is unidentified for the type math. I am not sure how to correct this. Any suggestions?
 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Works for me. It compiled and ran when I tried it.

Henry
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

One possibility. Did you happen to create your own Math class? And it is still in your classpath?

Henry
 
Sheriff
Posts: 4293
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maya tomarchio wrote:I used this code...

Please UseCodeTags (that's a link) when you post code.  I'll do it for you this time.
 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I can see another problem. I think it shou‍ld read
1 + rate, day
in line 8 if you want correct answers.
I think I would avoid the Math#pow method altogether.The multiplication is probably faster and will not be less accurate.

Henry is right in his second post; the only likely explanation is that you have your own Math class.
 
maya tomarchio
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much guys!! I did have a Math Class   I never would have figured that out on my own!
 
Campbell Ritchie
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maya tomarchio wrote:Thanks so much guys!! . . .
That's a pleasure We have seen that sort of problem before, so we recognised it quite quickly.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!