Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Geldanlage {
- public int t0, t_ende;
- public double B, z;
- public Geldanlage(int t_0, int tende, double b, double Z){
- t0 = t_0;
- t_ende = tende;
- B = b;
- z = Z;
- }
- public double auszahlung(int t) {
- double a;
- if (t == t0) {
- a = -B;
- } else if (t == t_ende){
- a = B * Math.pow((1+z),(t_ende - t0));
- } else{
- a = 0;
- }
- return a;
- }
- }
- public class Finanzplanung {
- public static void main(String[] args) {
- double[] b = new double[4];
- Geldanlage[] portfolio = new Geldanlage[3];
- portfolio[0] = new Geldanlage(2,5,100,0.03);
- portfolio[1] = new Geldanlage(4,8,200,0.025);
- portfolio[2] = new Geldanlage(6,9,150,0.017);
- for (int i = 1; i<=10; i++) {
- for (int j = 0; j<3; j++) {
- b[j] = portfolio[j].auszahlung(i);
- }
- b[3] = b[0] + b[1] + b[2];
- System.out.println("Jahr = " + i + ", Summe der Auszahlungen = " + b[3]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement