I just read your comment on your question:
What I try to make the code execute is an exponential function that given an initial value of c is capitalized in each period n and the payment of a fee of $ 360.84 is subtracted, and on the new value of c ...
maybe that would be to create another question (I advise you to do it), then
it's not about the error that you answered previously, and it's asking
help for something else;
Even so I will leave you this code for help in what you are looking for (it is possible that after a while I deleted it), I do not know what you are trying to achieve but according to your code maybe this is more or less what you are looking for , keep in mind what is happening below, since 360.84 may not be exact, for the last n, with which you would have to "return" or work that part, you subtract -1 an at the end because even though you could not enter the for previously has been added to the value a n.
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
/* se desea conocer el valor de n */
double n=1;
double c_final = 0;
for(double c=9500; c > 0; n+=1){
double z=Math.pow(1.018,n);
c=c+z;
c -= 360.84;
c_final = c;
System.out.println("Valor de c por iteracion "+c);
System.out.println("Valor de n por iteracion "+n);
}
System.out.println("tener en cuenta que cuando entra en la ultima iteracion c es mayor que 0 pero con las operaciones de dentro c puede aignar negativo por ejemplo " +c_final);
System.out.println("La cantidad de cuotas son "+(n-1));
}
}
Valor de c por iteracion 9140.178
Valor de n por iteracion 1.0
Valor de c por iteracion 8780.374324
Valor de n por iteracion 2.0
Valor de c por iteracion 8420.589301832
Valor de n por iteracion 3.0
Valor de c por iteracion 8060.823269264976
Valor de n por iteracion 4.0
Valor de c por iteracion 7701.0765681117455
Valor de n por iteracion 5.0
Valor de c por iteracion 7341.349546337757
Valor de n por iteracion 6.0
Valor de c por iteracion 6981.642558171836
Valor de n por iteracion 7.0
Valor de c por iteracion 6621.955964218929
Valor de n por iteracion 8.0
Valor de c por iteracion 6262.2901315748695
Valor de n por iteracion 9.0
Valor de c por iteracion 5902.645433943217
Valor de n por iteracion 10.0
Valor de c por iteracion 5543.022251754194
Valor de n por iteracion 11.0
Valor de c por iteracion 5183.4209722857695
Valor de n por iteracion 12.0
Valor de c por iteracion 4823.8419897869135
Valor de n por iteracion 13.0
Valor de c por iteracion 4464.285705603078
Valor de n por iteracion 14.0
Valor de c por iteracion 4104.752528303933
Valor de n por iteracion 15.0
Valor de c por iteracion 3745.242873813404
Valor de n por iteracion 16.0
Valor de c por iteracion 3385.757165542045
Valor de n por iteracion 17.0
Valor de c por iteracion 3026.2958345218017
Valor de n por iteracion 18.0
Valor de c por iteracion 2666.859319543194
Valor de n por iteracion 19.0
Valor de c por iteracion 2307.448067294971
Valor de n por iteracion 20.0
Valor de c por iteracion 1948.0625325062808
Valor de n por iteracion 21.0
Valor de c por iteracion 1588.703178091394
Valor de n por iteracion 22.0
Valor de c por iteracion 1229.370475297039
Valor de n por iteracion 23.0
Valor de c por iteracion 870.0649038523859
Valor de n por iteracion 24.0
Valor de c por iteracion 510.7869521217289
Valor de n por iteracion 25.0
Valor de c por iteracion 151.53711725992008
Valor de n por iteracion 26.0
Valor de c por iteracion -207.68409462940127
Valor de n por iteracion 27.0
tener en cuenta que cuando entra en la ultima iteracion c es mayor que 0 pero con las operaciones de dentro c puede aignar negativo por ejemplo -207.68409462940127
La cantidad de cuotas son 27.0
UPDATE: for your profile - > National Public Accountant Study
Please , be this example what you are looking for (or any other), do not use it to do financial operations, without first making sure that you do the operations in the right way (which is wait) it is not enough just to compile, for example you could assign to c
a lower value and calculate it yourself to make sure that the result is what you wanted for example with c = 1000
and take into account other things like this could be part - > double z=Math.pow(1.018,n);
maybe it does not work as you think, in this case n increases its value with each iteration something like this:
double z=Math.pow(1.018,1);
double z=Math.pow(1.018,2);
double z=Math.pow(1.018,3);
if that is what you expect great, but you may want to know how much is the final value for n
before applying double z=Math.pow(1.018,n);
in each iteration or apply in any other way ect.
On the other hand, you may want to look at this class Currency
or BigDecimal
to represent the decimal values in your operations in this type of financial operations.
Maybe this page is useful, where some examples of the results are shown when using different types of data.