Skip to content

Instantly share code, notes, and snippets.

@Fundibalus
Created April 13, 2016 15:02
Show Gist options
  • Save Fundibalus/3c672cc2ad5d31f91b9d6c390726760d to your computer and use it in GitHub Desktop.
Save Fundibalus/3c672cc2ad5d31f91b9d6c390726760d to your computer and use it in GitHub Desktop.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package og11;
/**
*
* @author Marlon
*/
public class Bank {
public Konto testKonto;
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package og11;
/**
*
* @author Marlon
*/
public class Konto {
boolean versuche = true;
private double kontostand = 100;
double Abheben(double abhbetrag) {
if(kontostand < 0) {
if(versuche == true) {
double überzogen = 0;
versuche = false;
return überzogen;
}
if(versuche == false) {
double überzogen = -1;
versuche = false;
return überzogen;
}
}
kontostand = kontostand - abhbetrag;
return abhbetrag;
}
}
package og11;
import java.util.Scanner;
public class OG11 {
public static void main(String[] args) {
boolean go = true;
Bank Volksbank = new Bank();
Bank Sparkasse = new Bank();
Konto konto1 = new Konto();
while(go == true) {
double abhebebetrag;
double ergbetrag;
Scanner scan1 = new Scanner(System.in);
abhebebetrag = scan1.nextDouble();
ergbetrag = konto1.Abheben(abhebebetrag);
System.out.println(ergbetrag);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment