Advertisement
hercioneto

Classe valores

Nov 28th, 2023
795
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. /**
  2.  *
  3.  * @author Professor Hercio Neto
  4.  */
  5. public class Valores {
  6.  
  7.     private Integer anos;
  8.     private Double juros, valor;
  9.  
  10.     public Integer getAnos() {
  11.         return anos*12;
  12.     }
  13.  
  14.     public void setAnos(Integer anos) {
  15.         this.anos = anos;
  16.     }
  17.  
  18.     public Double getJuros() {
  19.         return juros;
  20.     }
  21.  
  22.     public void setJuros(Double juros) {
  23.         this.juros = juros/100;
  24.     }
  25.  
  26.     public Double getValor() {
  27.         return valor;
  28.     }
  29.  
  30.     public void setValor(Double valor) {
  31.         this.valor = valor;
  32.     }
  33.    
  34.      public double calcularGanhosPoupanca() {
  35.  
  36.        
  37.          // Fórmula: F = P * (1 + i)^n + M * [(1 + i)^n - 1] / i
  38.  
  39.         double parte1 = 0 * Math.pow((1 + this.getJuros()), this.getAnos());
  40.         double parte2 = this.getValor() * ((Math.pow((1 + this.getJuros()), this.getAnos()) - 1) / this.getJuros());
  41.  
  42.         return parte1 + parte2;
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement