-
-
Save codecademydev/78516fec13ab280689ff6ad1339bba79 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 "+savings.balance); | |
} | |
public static void main(String[] args){ | |
SavingsAccount savings = new SavingsAccount(2000); | |
System.out.println(checkBalance); | |
//Withdrawing: | |
int afterWithdraw = savings.balance - 300; | |
savings.balance = afterWithdraw; | |
System.out.println("You just withdrew "+300); | |
//Check balance: | |
System.out.println("Hello!"); | |
System.out.println("Your balance is "+savings.balance); | |
//Deposit: | |
int afterDeposit = savings.balance + 600; | |
savings.balance = afterDeposit; | |
System.out.println("You just deposited "+600); | |
//Check balance: | |
System.out.println("Hello!"); | |
System.out.println("Your balance is "+savings.balance); | |
//Deposit: | |
int afterDeposit2 = savings.balance + 600; | |
savings.balance = afterDeposit2; | |
System.out.println("You just deposited "+600); | |
//Check balance: | |
System.out.println("Hello!"); | |
System.out.println("Your balance is "+savings.balance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment