Also jetzt passt mal auf ihr Deppen, das geht so ja:
Code:
package konto;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Konto
{
private double kontostand, einzahlung, abhebung = 0.;
private int funktion = -1;
//TODO: exception handling, verify inputs
public void doKonto() throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while (true)
{
System.out.print("Funktion waehlen: ");
funktion = Integer.valueOf(br.readLine());
switch (funktion)
{
case 1:
{
System.out.println("Kontostand = "+kontostand);
break;
}
case 2:
{
System.out.print("Betrag einzahlen: ");
einzahlung = Double.valueOf(br.readLine());
kontostand += einzahlung;
einzahlung = 0;
break;
}
case 3:
{
System.out.print("Abhebung in Hoehe von: ");
abhebung = Double.valueOf(br.readLine());
if (abhebung > kontostand)
{
System.out.println("Konto nicht gedeckt.");
}
else
{
kontostand -= abhebung;
}
abhebung = 0;
break;
}
case 0:
{
System.exit(0);
}
}
}
}
public static void main(String[] args) throws IOException
{
Konto konto = new Konto();
konto.doKonto();
}
}
Viel Glück dann am Montag du Pfosten.