Need Help with Java Code problem is with the math?

Answer Your first calculation should be the correct one, since yes, you do need powers.However, you're printing the result of the second, wrong calculation.This should work:> double total = investment * M... Read More »

Top Q&A For: Need Help with Java Code problem is with the math

Rounding problem in Java?

This has to do with binary math on 32-bit registers. Your handheld calculator is 48-bit. Your value rounded to the closest integer (int) which has no decimals. So, I use the String.format() method.... Read More »

Help with Java programming problem?

I just googled "java length of string" and it brought me to this page. That's all you have to do, and I found a link to the java documentation of the string class. Read More »

Overflow problem in java?

How to get the powerof N without using a Math class in java?

Use a for loop. For example the following function returns the answer as an integer:private int printPowersOfN(int main, int power){int answer = main;for(int i = 1;i < power;i++){answer = answer * ... Read More »