Hello, I'm having a project of a consortium calculator that is showing error. It receives the following data from the user:
- Consortium value
- Number of months
- % of reserve fund
- % of administrative fee
After this it calculates the value of the monthly installment.
My problem is this: If I put the amount of months 10 works if putting 15 already gives error.
Follow the code:
BigDecimal cota = new BigDecimal(jTextField1.getText());
BigDecimal prazo = new BigDecimal(jTextField2.getText());
BigDecimal reserva = new BigDecimal(jTextField3.getText());
BigDecimal adm = new BigDecimal(jTextField4.getText());
DecimalFormat decimal = new DecimalFormat("0.##");
//Calculo Fundo Comum
BigDecimal pc = new BigDecimal("100");
BigDecimal percentualMensal = pc.divide(prazo);
BigDecimal parcelaMensal = percentualMensal.multiply(cota);
BigDecimal parcelaMensal1 = parcelaMensal.divide(pc);
//Calculo Taxa Administrativa
BigDecimal a1 = adm.divide(prazo);
BigDecimal parcelaAdm = a1.multiply(cota);
BigDecimal parcelaAdm1 = parcelaAdm.divide(pc);
//Calculo Fundo Reserva
BigDecimal r1 = reserva.divide(prazo);
BigDecimal parcelaReserva = cota.multiply(r1);
BigDecimal parcelaReserva1 = parcelaReserva.divide(pc);
BigDecimal calculo = parcelaMensal1.add(parcelaAdm1.add(parcelaReserva1));
String a = decimal.format(calculo);
jLabel5.setText("Valor: "+a);