diff --git a/BankingSystem.java b/BankingSystem.java new file mode 100644 index 0000000000..072897ebb7 --- /dev/null +++ b/BankingSystem.java @@ -0,0 +1,43 @@ +public class BankingSystem { + private String owner; + private double balance; + + public BankingSystem(String owner, double initialBalance) { + this.owner = owner; + this.balance = initialBalance; + } + + public void deposit(double amount) { + if (amount > 0) { + balance += amount; + } + } + + public void withdraw(double amount) { + if (amount <= balance) { + balance -= amount; + } + } + + public double getBalance() { + return balance; + } + + public void displayAccountInfo() { + System.out.println("Account Owner: " + owner); + System.out.println("Account Balance: $" + balance); + } + + public static void main(String[] args) { + BankingSystem userAccount = new BankingSystem("John Doe", 1000.0); + userAccount.displayAccountInfo(); + + userAccount.deposit(500.0); + userAccount.displayAccountInfo(); + + userAccount.withdraw(300.0); + userAccount.displayAccountInfo(); + + System.out.println("\nCurrent Balance: $" + userAccount.getBalance()); + } +} diff --git a/example.html b/example.html new file mode 100644 index 0000000000..67bcc894a6 --- /dev/null +++ b/example.html @@ -0,0 +1,22 @@ + + +
+ + +