public static void main(String[] args) { test(2); test(1); } private static double Kontostand = 0d; public static void test (int Funktion) { // (Zugriffs-) Methoden switch (Funktion){ // (1) Kontostand abfragen // Aktueller Kontostand wird ausgegeben case 1: { System.out.println ("Dein Guthaben beträgt: "+Kontostand+"€"); break; } // (2) Einzahlen auf das Konto // Kontostand wird um Einzahlung erhöht case 2: { double einzahlen = (50.0); Kontostand += einzahlen; System.out.println ("Du hast: "+einzahlen+"€ eingezahlt."); break; } // (3) Abheben vom Konto // Konto darf nicht ins Negative gehen: in diesem Fall // soll kein Abheben erfolgen und statt dessen ein // entsprechender Hinweis ausgegeben werden case 3: { double abheben = (20.0); if (Kontostand < abheben) System.out.println ("Du kannst nicht mehr Geld abheben als du besitzt!"); else Kontostand -= abheben; System.out.println ("Du hast: "+abheben+"€ angehoben"); break; } //Blablub default: { System.out.println ("Falsche Eingabe!"); } } }