Advertisement
Guest User

FInanzplanung

a guest
Dec 16th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. class Geldanlage {
  2.     public int t0, t_ende;
  3.     public double B, z;
  4.     public Geldanlage(int t_0, int tende, double b, double Z){
  5.         t0 = t_0;
  6.         t_ende = tende;
  7.         B = b;
  8.         z = Z;
  9.     }
  10.     public double auszahlung(int t) {
  11.         double a;
  12.         if (t == t0) {
  13.             a = -B;
  14.         } else if (t == t_ende){
  15.             a = B * Math.pow((1+z),(t_ende - t0));
  16.         } else{
  17.             a = 0;
  18.         }
  19.         return a;
  20.     }
  21. }
  22.  
  23. public class Finanzplanung {
  24.     public static void main(String[] args) {
  25.         double[] b = new double[4];
  26.         Geldanlage[] portfolio = new Geldanlage[3];
  27.         portfolio[0] = new Geldanlage(2,5,100,0.03);
  28.         portfolio[1] = new Geldanlage(4,8,200,0.025);
  29.         portfolio[2] = new Geldanlage(6,9,150,0.017);
  30.         for (int i = 1; i<=10; i++) {
  31.             for (int j = 0; j<3; j++) {
  32.                 b[j] = portfolio[j].auszahlung(i);
  33.             }
  34.             b[3] = b[0] + b[1] + b[2];
  35.             System.out.println("Jahr = " + i + ", Summe der Auszahlungen = " + b[3]);
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement