-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompound.java
More file actions
99 lines (79 loc) · 1.99 KB
/
compound.java
File metadata and controls
99 lines (79 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package textoSecreto;
/**
*
* @author danielsalnikov
*/
public class compound extends Bonos {
public compound(String n, double d, double i, int a, String t) {
super(n, d, i, a, t);
}
public double compuesto(int a, double i, double p) {
double ut;
if (i > 1) {
i = i * .01;
}
if (a == 0) {
ut = p;
} else {
ut = compuesto(a - 1, i, p * (1 + i));
}
return ut;
}
@Override
public String toString() {
return "Bond: "+nombre+"\n"
+"Principal: $"+this.valPrinc+"\n"
+"Interest rate (decimal): "+this.interes+"\n"
+"Duration: "+this.duracion+" years\n"
+"Type: "+this.tipo+"\n\n";
}
public double getInteres() {
return interes;
}
public void setInteres(double interes) {
this.interes = interes;
}
public int getDuracion() {
return duracion;
}
public void setDuracion(int duracion) {
this.duracion = duracion;
}
public String getTipo() {
return tipo;
}
public void setTipo(String tipo) {
this.tipo = tipo;
}
@Override
public String getNombre() {
return nombre;
}
@Override
public void setNombre(String nombre) {
this.nombre = nombre;
}
public double getValPrinc() {
return valPrinc;
}
public void setValPrinc(double valPrinc) {
this.valPrinc = valPrinc;
}
@Override
public double Rendimiento() {
double ren;
ren = compuesto(this.duracion, this.interes, this.valPrinc);
return ren;
}
@Override
public double utilidad() {
double uti;
uti = Rendimiento()-this.valPrinc;
return uti;
}
}