Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author Professor Hercio Neto
- */
- public class Valores {
- private Integer anos;
- private Double juros, valor;
- public Integer getAnos() {
- return anos*12;
- }
- public void setAnos(Integer anos) {
- this.anos = anos;
- }
- public Double getJuros() {
- return juros;
- }
- public void setJuros(Double juros) {
- this.juros = juros/100;
- }
- public Double getValor() {
- return valor;
- }
- public void setValor(Double valor) {
- this.valor = valor;
- }
- public double calcularGanhosPoupanca() {
- // Fórmula: F = P * (1 + i)^n + M * [(1 + i)^n - 1] / i
- double parte1 = 0 * Math.pow((1 + this.getJuros()), this.getAnos());
- double parte2 = this.getValor() * ((Math.pow((1 + this.getJuros()), this.getAnos()) - 1) / this.getJuros());
- return parte1 + parte2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement