Hallo Forum,
an diesen Programm hänge ich schon seit Stunden aber ich bekomme es nicht zu laufen.
Vielleicht kann sich das mal einer ansehen:
Danke!
an diesen Programm hänge ich schon seit Stunden aber ich bekomme es nicht zu laufen.
Vielleicht kann sich das mal einer ansehen:
Code:
package javaapplication1;
public int add(int value);
public int withdraw(int value);
public void info(int value);
private int total;
public Sparbuch(int value)
{
this.value =value;
this.total = value;
}
public class Sparbuch
{
private int total;
private int value;
public Sparbuch(int value)
{
this.value = value;
this.total = value;
}
public int withdraw(int amount)
{
//Geld abheben
}
public int add(int amount)
{
//Geld einzahlen
}
public void info(int value)
{
//Kontostand anzeigen
}
public static void main(String[] args)
{
Sparbuch s = new Sparbuch(500);
}
}
public int add(int amount)
{
total = amount;
return total++;
}
public int withdraw(int amount)
{
amount = total;
total--;
if (total <= 0)
System.out.println("Keine Auszahllung möglich! Ihr Kontostand ist: " +total);
return total;
}
public void info(int value)
{
if(value <= 0)
System.out.println("Warnung! Kontostand: " -value);
else
{
total = total + value;
System.out.println("Kontostand: " +total);
}
}
int x = s.add(value);//Kontostand speichern
s.info(x);//Wert von Kontostand an info() übergeben
public static void main(String[[] args)
{
BufferedReader in = new BufferedReader(new InputSreamReader(System.in));
int x =0;
Sparbuch s = new Sparbuch(500);
System.out.println("Wilkommen bei der Sparkasse.");
System.out.println("Wählen Sie eine Aktion aus!");
System.out.println("1. Geld einzahlen");
System.out.println("2. Geld abheben");
System.out.println("3. Kontostand anzeigen");
System.out.println("4. Beenden");
try
{
int option = Integer.parseInt{int.readLine()};
switch(option)
{
case 1:
{
System.out.println("Betrag eingeben: ");
int value = Integer.parseInt(in.readLine());
x = s.add(value);
s.info(x);
}
break;
case 2:
{
System.out.println("Betrag eingeben: ");
int value = Integer.parseInt(in.readLine());
x = s.withdraw(value);
s.info(x);
}
break;
case 3:
{
System.out.println("Ihr Kontostand: ");
s.showTotal();
}
break;
case 4:
{
System.exit(0);
}
}
}
catch (Exception e)
{
}
}
Danke!