Do you know how to write a small program for testing a statement?
Type: Posts; User: Norm
Do you know how to write a small program for testing a statement?
What did you mean in post#29? "round down to 0"
Do some experimenting with casting double values to int to see what happens. Write a short test program with this statement. Compile and execute...
I don't understand your last post. What does "suppose to see" mean?
Do you know what is causing interest to be zero?
Do you know how to change the code to keep interest from being zero?
0.004 is a double and doesn't need to be cast to double.
What happens to 0.004 when it is converted to an int?
Look at the code that assigns a value to the variable: interest
What happens to the value: (annualInterest/12) before it is assigned to interest?
I'm not asking for an equation. I'm asking for real numbers like: 3 or 4.55 or 0.444444
The objective is to get a good value assigned to the variable: interest
What value do you expect to be...
Why can't you answer the simple question: given annualInterest of 0.05 what value do you want assigned to the variable: interest?
When you have that value, then look at the code to see why that...
That's a value for annualInterest. Now what is the value for the interest that the code is supposed to compute?
If you don't know what the code is supposed to do, it is very hard to write a...
Can you post some sample numbers for the variables: annualInterest and interest?
For example: 24 and 2
I'm trying to determine what you want that line of code to do. What value of annualInterest is used in the equation? What value do you want to be assigned to the variable: interest? Can you give...
Can you give an example of the calculation with actual numbers?
For example: 20.0/12 = 1.66667
Can you give an example of the calculation with actual numbers?
For example: 20.0/12 = 1.66667
Can you give an example of the calculation with actual numbers?
Use the println() method to print its value so you can see what it is.
interest = (int) ((double)annualInterest / 12);
What value for interest do you want from this statement?
Can you give an...
The error message says that the code on line 53 tried to divide by zero. Since that is not defined the jvm threw an exception.
The code should test that the divisor is not zero before trying to...
Can you give more details about what the problem is? Copy the output, paste it here and add some comments saying what is wrong and show what you want the output to be.