Einzelnen Beitrag anzeigen
Ungelesen 03.02.12, 18:29   #6
wasili_dsw
Anfänger
 
Registriert seit: Aug 2011
Beiträge: 2
Bedankt: 0
wasili_dsw ist noch neu hier! | 0 Respekt Punkte
Standard

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.
wasili_dsw ist offline   Mit Zitat antworten