Allen Paulo V.
Caya
BSIT 2-A
import java.util.Scanner;
class Account {
public String name;
public int id;
private double balance;
public Account(String name, int id, double balance) {
this.name = name;
this.id = id;
this.balance = balance;
public void displayAccountInfo() {
System.out.println("\n═══════════════════════════════════════");
System.out.println("Account Name: " + name);
System.out.println("Account ID: " + id);
System.out.println("Account Balance: PHP" + balance);
public void deposit(double amount) {
balance += amount;
System.out.println("Success! New Balance: PHP" + balance);
public void withdraw(double amount) {
if (amount > balance) {
System.out.println("Insufficient funds. Your current balance is: PHP" + balance);
} else {
balance -= amount;
System.out.println("Success! New Balance: PHP" + balance);
protected double getBalance() {
return balance;
protected void setBalance(double balance) {
this.balance = balance;
class SavingsAccount extends Account {
private double interestRate;
private double yearsInBank;
public SavingsAccount(String name, int id, double balance, double interestRate, double yearsInBank) {
super(name, id, balance);
this.interestRate = interestRate;
this.yearsInBank = yearsInBank;
public double computeInterest() {
return getBalance() * interestRate * yearsInBank;
}
public void updateBalance() {
double updatedBalance = getBalance() + computeInterest();
setBalance(updatedBalance);
System.out.println("Balance updated! Your new balance is: PHP" + updatedBalance);
public void actionChoose(Scanner scanner) {
boolean exit = false;
while (!exit) {
System.out.println("═══════════════════════════════════════");
System.out.println("Choose an option for " + name + "\nAccount ID: [" + id + "] \nBalance: [PHP" +
getBalance() + "]\n═══════════════════════════════════════");
System.out.println("1. Show Account Details");
System.out.println("2. Banking System");
System.out.println("3. Logout");
System.out.println("0. Exit\
n═══════════════════════════════════════");
System.out.print("Enter your choice: ");
int choice = scanner.nextInt();
scanner.nextLine(); // Consume newline
switch (choice) {
case 1:
displayAccountInfo();
break;
case 2:
bankingSystem(scanner);
break;
case 3:
exit = true;
break;
case 0:
exit = true;
System.out.println("Thank you for using our ATM! Arigato!");
break;
default:
System.out.println("Invalid Input!");
break;
private void bankingSystem(Scanner scanner) {
boolean exit = false;
while (!exit) {
System.out.println("═══════════════════════════════════════");
System.out.println("Banking System");
System.out.println("1. Deposit");
System.out.println("2. Withdraw");
System.out.println("3. Back");
System.out.println("4. Exit\
n═══════════════════════════════════════");
System.out.print("Enter your choice: ");
int bankingChoice = scanner.nextInt();
scanner.nextLine(); // Consume newline
switch (bankingChoice) {
case 1:
System.out.print("Enter amount to deposit: PHP");
double deposit = scanner.nextDouble();
scanner.nextLine(); // Consume newline
deposit(deposit);
break;
case 2:
System.out.print("Enter amount to withdraw: PHP");
double withdraw = scanner.nextDouble();
scanner.nextLine(); // Consume newline
withdraw(withdraw);
break;
case 3:
exit = true;
break;
case 4:
exit = true;
System.out.println("Exiting the banking system. Thank you!");
break;
default:
System.out.println("Invalid Input!");
break;
class CurrentAccount extends Account {
public CurrentAccount(String name, int id, double balance) {
super(name, id, balance);
@Override
public void displayAccountInfo() {
super.displayAccountInfo();
if (getBalance() < 100) {
System.out.println("═══════════════════════════════════════");
System.out.println("WARNING: Your balance is below 100.");
public void actionChoose(Scanner scanner) {
// Implement the actionChoose method for the CurrentAccount class if needed
// You can display a menu and handle user actions here.
class ATM {
public static void main(String[] args) {
start();
private static void start() {
clearConsole();
Scanner scanner = new Scanner(System.in);
System.out.println("═══════════════════════════════════════");
System.out.println("Choose an account: ");
System.out.println("1. Caya Allen");
System.out.println("2. Llanes Jayson");
System.out.println("3. Lee Bruce");
System.out.println("0. Exit");
System.out.println("═══════════════════════════════════════");
System.out.print("Enter the account number: ");
int acc = scanner.nextInt();
scanner.nextLine(); // Consume newline
switch (acc) {
case 1:
SavingsAccount acc1 = new SavingsAccount("Caya Allen Paulo", 10001101, 25000, 0.05, 1);
acc1.actionChoose(scanner);
break;
case 2:
CurrentAccount acc2 = new CurrentAccount("Llanes Jayson", 10001011, 30000);
acc2.actionChoose(scanner);
break;
case 3:
SavingsAccount acc3 = new SavingsAccount("Silvester Stalone", 10000011, 45000, 0.05, 1);
acc3.actionChoose(scanner);
break;
case 0:
System.out.println("Byebyeeee");
break;
default:
System.out.println("Invalid Input!");
break;
}
scanner.close();
// Other methods remain the same
private static void clearConsole() {
// Clear console code