-
-
Save codecademydev/f7138ac8a7aeb56675b121e15edf3ad9 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SavingsAccount { | |
int balance; | |
public SavingsAccount(int initialBalance){ | |
balance = initialBalance; | |
} | |
public void checkBalance() { | |
System.out.println("Hello!"); | |
System.out.println("Your balance is " + balance); | |
} | |
public void deposit(int amountToDeposit) { | |
balance = balance + amountToDeposit; | |
System.out.println("You just deposited " + amountToDeposit); | |
System.out.println(balance); | |
} | |
public int withdraw(int amountToWithdraw) { | |
balance = balance - amountToWithdraw; | |
System.out.println("You just withdrew " + amountToWithdraw); | |
System.out.println(balance); | |
return amountToWithdraw; | |
} | |
public static void main(String[] args){ | |
SavingsAccount savings = new SavingsAccount(2000); | |
savings.checkBalance(); | |
savings.deposit(150); | |
savings.withdraw(300); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment