fork download
  1. class UserAccount {
  2. public static void main(String[] args){
  3.  
  4. UserAccount Vasia = new UserAccount("Vasia Pupkin",5000);
  5. Vasia.payout(5001);
  6. Vasia.payment(102);
  7. Vasia.getbalance();
  8.  
  9. }
  10. public String name;
  11. public double money;
  12.  
  13. public UserAccount(String name, double money){
  14. this.name = name;
  15. this.money = money;
  16. }
  17.  
  18. public double payout(double countMoney){
  19. this.money -= countMoney;
  20. if (this.money <= 0){
  21. System.out.println("Not enough money");
  22. this.money += countMoney;
  23. return this.money;
  24. }
  25.  
  26. else {
  27. return this.money;
  28. }
  29. }
  30. public double payment(double countMoney){
  31. this.money = this.money + countMoney;
  32. return this.money;
  33. }
  34. public void getbalance(){
  35. System.out.println(name + " have " + money + " dollars");
  36. }
  37. }
Success #stdin #stdout 0.09s 320512KB
stdin
Standard input is empty
stdout
Not enough money
Vasia Pupkin have 5102.0 dollars