From 3e13cca5271359b412f6da662406c440e888828e Mon Sep 17 00:00:00 2001 From: chittakushal <111438028+chittakushal@users.noreply.github.com> Date: Sat, 4 May 2024 19:27:55 +0530 Subject: [PATCH 1/4] Add files via upload --- HospitalSystemDemo.java | 134 ++++++++++++++++++++++++++++++++++ Main.java | 154 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 288 insertions(+) create mode 100644 HospitalSystemDemo.java create mode 100644 Main.java diff --git a/HospitalSystemDemo.java b/HospitalSystemDemo.java new file mode 100644 index 0000000..1eca880 --- /dev/null +++ b/HospitalSystemDemo.java @@ -0,0 +1,134 @@ +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +class Patient { + private String name; + private int age; + private String gender; + private String address; + private String phoneNumber; + + public Patient(String name, int age, String gender, String address, String phoneNumber) { + this.name = name; + this.age = age; + this.gender = gender; + this.address = address; + this.phoneNumber = phoneNumber; + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return "Name: " + name + ", Age: " + age + ", Gender: " + gender + ", Address: " + address + ", Phone: " + phoneNumber; + } +} + +class HospitalManagementSystem { + private List patientRecords; + private Map> appointmentSchedule; + + public HospitalManagementSystem() { + patientRecords = new ArrayList<>(); + appointmentSchedule = new HashMap<>(); + } + + public void addPatientRecord(Patient patient) { + patientRecords.add(patient); + } + + public void scheduleAppointment(Date date, Patient patient) { + appointmentSchedule.computeIfAbsent(date, k -> new ArrayList<>()).add(patient); + } + + public void displayPatientRecords() { + System.out.println("Patient Records:"); + for (Patient patient : patientRecords) { + System.out.println(patient); + } + } + + public void displayAppointmentSchedule() { + System.out.println("Appointment Schedule:"); + for (Map.Entry> entry : appointmentSchedule.entrySet()) { + System.out.println("Date: " + entry.getKey()); + System.out.println("Patients:"); + for (Patient patient : entry.getValue()) { + System.out.println(patient); + } + System.out.println(); + } + } + + public Patient getPatientByName(String name) { + for (Patient patient : patientRecords) { + if (patient.getName().equals(name)) { + return patient; + } + } + return null; + } +} + +public class HospitalSystemDemo { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + HospitalManagementSystem hospitalSystem = new HospitalManagementSystem(); + + System.out.println("Enter patient information (name, age, gender, address, phone), type 'done' to finish:"); + while (true) { + System.out.print("Patient name: "); + String name = scanner.nextLine(); + if (name.equals("done")) break; + System.out.print("Patient age: "); + int age = Integer.parseInt(scanner.nextLine()); + System.out.print("Patient gender: "); + String gender = scanner.nextLine(); + System.out.print("Patient address: "); + String address = scanner.nextLine(); + System.out.print("Patient phone number: "); + String phoneNumber = scanner.nextLine(); + + hospitalSystem.addPatientRecord(new Patient(name, age, gender, address, phoneNumber)); + } + + System.out.println("Enter appointment scheduling (date YYYY-MM-DD, patient name), type 'done' to finish:"); + while (true) { + System.out.print("Date (YYYY-MM-DD): "); + String dateString = scanner.nextLine(); + if (dateString.equals("done")) break; + System.out.print("Patient name: "); + String patientName = scanner.nextLine(); + + Date date = parseDate(dateString); + if (date != null) { + Patient patient = hospitalSystem.getPatientByName(patientName); + if (patient != null) { + hospitalSystem.scheduleAppointment(date, patient); + } else { + System.out.println("Patient not found."); + } + } else { + System.out.println("Invalid date format."); + } + } + + hospitalSystem.displayPatientRecords(); + hospitalSystem.displayAppointmentSchedule(); + + scanner.close(); + } + + private static Date parseDate(String dateString) { + try { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + return dateFormat.parse(dateString); + } catch (ParseException e) { + System.out.println("Error parsing date: " + e.getMessage()); + return null; + } + } +} \ No newline at end of file diff --git a/Main.java b/Main.java new file mode 100644 index 0000000..0444687 --- /dev/null +++ b/Main.java @@ -0,0 +1,154 @@ +import java.util.HashMap; +import java.util.Map; +import java.util.Scanner; + +class BankAccount { + private String accountNumber; + private double balance; + private Map transactionHistory; + + public BankAccount(String accountNumber, double initialBalance) { + this.accountNumber = accountNumber; + this.balance = initialBalance; + this.transactionHistory = new HashMap<>(); + } + + public void deposit(double amount) { + balance += amount; + transactionHistory.put("Deposit", amount); + } + + public boolean withdraw(double amount) { + if (balance >= amount) { + balance -= amount; + transactionHistory.put("Withdrawal", -amount); + return true; + } + return false; + } + + public double getBalance() { + return balance; + } + + public Map getTransactionHistory() { + return transactionHistory; + } +} + +class OnlineBankingSystem { + private Map accounts; + private Scanner scanner; + + public OnlineBankingSystem() { + accounts = new HashMap<>(); + scanner = new Scanner(System.in); + } + + public void createAccount() { + System.out.println("Enter account number:"); + String accountNumber = scanner.nextLine(); + System.out.println("Enter initial balance:"); + double initialBalance = scanner.nextDouble(); + scanner.nextLine(); // Consume newline + BankAccount account = new BankAccount(accountNumber, initialBalance); + accounts.put(accountNumber, account); + System.out.println("Account created successfully."); + } + + public void deposit() { + System.out.println("Enter account number:"); + String accountNumber = scanner.nextLine(); + BankAccount account = accounts.get(accountNumber); + if (account != null) { + System.out.println("Enter deposit amount:"); + double amount = scanner.nextDouble(); + scanner.nextLine(); // Consume newline + account.deposit(amount); + System.out.println("Deposit successful."); + } else { + System.out.println("Account not found."); + } + } + + public void withdraw() { + System.out.println("Enter account number:"); + String accountNumber = scanner.nextLine(); + BankAccount account = accounts.get(accountNumber); + if (account != null) { + System.out.println("Enter withdrawal amount:"); + double amount = scanner.nextDouble(); + scanner.nextLine(); // Consume newline + if (account.withdraw(amount)) { + System.out.println("Withdrawal successful."); + } else { + System.out.println("Insufficient balance."); + } + } else { + System.out.println("Account not found."); + } + } + + public void displayBalance() { + System.out.println("Enter account number:"); + String accountNumber = scanner.nextLine(); + BankAccount account = accounts.get(accountNumber); + if (account != null) { + System.out.println("Current balance: " + account.getBalance()); + } else { + System.out.println("Account not found."); + } + } + + public void displayTransactionHistory() { + System.out.println("Enter account number:"); + String accountNumber = scanner.nextLine(); + BankAccount account = accounts.get(accountNumber); + if (account != null) { + System.out.println("Transaction History:"); + Map history = account.getTransactionHistory(); + for (Map.Entry entry : history.entrySet()) { + System.out.println(entry.getKey() + ": " + entry.getValue()); + } + } else { + System.out.println("Account not found."); + } + } +} + +public class Main { + public static void main(String[] args) { + OnlineBankingSystem bankingSystem = new OnlineBankingSystem(); + Scanner scanner = new Scanner(System.in); + + while (true) { + System.out.println("\n1. Create Account\n2. Deposit\n3. Withdraw\n4. Display Balance\n5. Display Transaction History\n6. Exit\n"); + System.out.println("Enter your choice:"); + int choice = scanner.nextInt(); + scanner.nextLine(); + switch (choice) { + case 1: + bankingSystem.createAccount(); + break; + case 2: + bankingSystem.deposit(); + break; + case 3: + bankingSystem.withdraw(); + break; + case 4: + bankingSystem.displayBalance(); + break; + case 5: + bankingSystem.displayTransactionHistory(); + break; + case 6: + System.out.println("Exiting..."); + scanner.close(); + System.exit(0); + default: + System.out.println("Invalid choice. Please enter a number from 1 to 6."); + } + } + } +} From 178e4c75eba869bb8e8d6b0fdecd5a9827032fd5 Mon Sep 17 00:00:00 2001 From: chittakushal <111438028+chittakushal@users.noreply.github.com> Date: Sat, 4 May 2024 19:45:57 +0530 Subject: [PATCH 2/4] Delete Main.java --- Main.java | 154 ------------------------------------------------------ 1 file changed, 154 deletions(-) delete mode 100644 Main.java diff --git a/Main.java b/Main.java deleted file mode 100644 index 0444687..0000000 --- a/Main.java +++ /dev/null @@ -1,154 +0,0 @@ -import java.util.HashMap; -import java.util.Map; -import java.util.Scanner; - -class BankAccount { - private String accountNumber; - private double balance; - private Map transactionHistory; - - public BankAccount(String accountNumber, double initialBalance) { - this.accountNumber = accountNumber; - this.balance = initialBalance; - this.transactionHistory = new HashMap<>(); - } - - public void deposit(double amount) { - balance += amount; - transactionHistory.put("Deposit", amount); - } - - public boolean withdraw(double amount) { - if (balance >= amount) { - balance -= amount; - transactionHistory.put("Withdrawal", -amount); - return true; - } - return false; - } - - public double getBalance() { - return balance; - } - - public Map getTransactionHistory() { - return transactionHistory; - } -} - -class OnlineBankingSystem { - private Map accounts; - private Scanner scanner; - - public OnlineBankingSystem() { - accounts = new HashMap<>(); - scanner = new Scanner(System.in); - } - - public void createAccount() { - System.out.println("Enter account number:"); - String accountNumber = scanner.nextLine(); - System.out.println("Enter initial balance:"); - double initialBalance = scanner.nextDouble(); - scanner.nextLine(); // Consume newline - BankAccount account = new BankAccount(accountNumber, initialBalance); - accounts.put(accountNumber, account); - System.out.println("Account created successfully."); - } - - public void deposit() { - System.out.println("Enter account number:"); - String accountNumber = scanner.nextLine(); - BankAccount account = accounts.get(accountNumber); - if (account != null) { - System.out.println("Enter deposit amount:"); - double amount = scanner.nextDouble(); - scanner.nextLine(); // Consume newline - account.deposit(amount); - System.out.println("Deposit successful."); - } else { - System.out.println("Account not found."); - } - } - - public void withdraw() { - System.out.println("Enter account number:"); - String accountNumber = scanner.nextLine(); - BankAccount account = accounts.get(accountNumber); - if (account != null) { - System.out.println("Enter withdrawal amount:"); - double amount = scanner.nextDouble(); - scanner.nextLine(); // Consume newline - if (account.withdraw(amount)) { - System.out.println("Withdrawal successful."); - } else { - System.out.println("Insufficient balance."); - } - } else { - System.out.println("Account not found."); - } - } - - public void displayBalance() { - System.out.println("Enter account number:"); - String accountNumber = scanner.nextLine(); - BankAccount account = accounts.get(accountNumber); - if (account != null) { - System.out.println("Current balance: " + account.getBalance()); - } else { - System.out.println("Account not found."); - } - } - - public void displayTransactionHistory() { - System.out.println("Enter account number:"); - String accountNumber = scanner.nextLine(); - BankAccount account = accounts.get(accountNumber); - if (account != null) { - System.out.println("Transaction History:"); - Map history = account.getTransactionHistory(); - for (Map.Entry entry : history.entrySet()) { - System.out.println(entry.getKey() + ": " + entry.getValue()); - } - } else { - System.out.println("Account not found."); - } - } -} - -public class Main { - public static void main(String[] args) { - OnlineBankingSystem bankingSystem = new OnlineBankingSystem(); - Scanner scanner = new Scanner(System.in); - - while (true) { - System.out.println("\n1. Create Account\n2. Deposit\n3. Withdraw\n4. Display Balance\n5. Display Transaction History\n6. Exit\n"); - System.out.println("Enter your choice:"); - int choice = scanner.nextInt(); - scanner.nextLine(); - switch (choice) { - case 1: - bankingSystem.createAccount(); - break; - case 2: - bankingSystem.deposit(); - break; - case 3: - bankingSystem.withdraw(); - break; - case 4: - bankingSystem.displayBalance(); - break; - case 5: - bankingSystem.displayTransactionHistory(); - break; - case 6: - System.out.println("Exiting..."); - scanner.close(); - System.exit(0); - default: - System.out.println("Invalid choice. Please enter a number from 1 to 6."); - } - } - } -} From 1d517c8a293ac03c4a93b88156f3df61a678c2c5 Mon Sep 17 00:00:00 2001 From: chittakushal <111438028+chittakushal@users.noreply.github.com> Date: Sat, 4 May 2024 19:46:16 +0530 Subject: [PATCH 3/4] Delete HospitalSystemDemo.java --- HospitalSystemDemo.java | 134 ---------------------------------------- 1 file changed, 134 deletions(-) delete mode 100644 HospitalSystemDemo.java diff --git a/HospitalSystemDemo.java b/HospitalSystemDemo.java deleted file mode 100644 index 1eca880..0000000 --- a/HospitalSystemDemo.java +++ /dev/null @@ -1,134 +0,0 @@ -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; - -class Patient { - private String name; - private int age; - private String gender; - private String address; - private String phoneNumber; - - public Patient(String name, int age, String gender, String address, String phoneNumber) { - this.name = name; - this.age = age; - this.gender = gender; - this.address = address; - this.phoneNumber = phoneNumber; - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return "Name: " + name + ", Age: " + age + ", Gender: " + gender + ", Address: " + address + ", Phone: " + phoneNumber; - } -} - -class HospitalManagementSystem { - private List patientRecords; - private Map> appointmentSchedule; - - public HospitalManagementSystem() { - patientRecords = new ArrayList<>(); - appointmentSchedule = new HashMap<>(); - } - - public void addPatientRecord(Patient patient) { - patientRecords.add(patient); - } - - public void scheduleAppointment(Date date, Patient patient) { - appointmentSchedule.computeIfAbsent(date, k -> new ArrayList<>()).add(patient); - } - - public void displayPatientRecords() { - System.out.println("Patient Records:"); - for (Patient patient : patientRecords) { - System.out.println(patient); - } - } - - public void displayAppointmentSchedule() { - System.out.println("Appointment Schedule:"); - for (Map.Entry> entry : appointmentSchedule.entrySet()) { - System.out.println("Date: " + entry.getKey()); - System.out.println("Patients:"); - for (Patient patient : entry.getValue()) { - System.out.println(patient); - } - System.out.println(); - } - } - - public Patient getPatientByName(String name) { - for (Patient patient : patientRecords) { - if (patient.getName().equals(name)) { - return patient; - } - } - return null; - } -} - -public class HospitalSystemDemo { - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - HospitalManagementSystem hospitalSystem = new HospitalManagementSystem(); - - System.out.println("Enter patient information (name, age, gender, address, phone), type 'done' to finish:"); - while (true) { - System.out.print("Patient name: "); - String name = scanner.nextLine(); - if (name.equals("done")) break; - System.out.print("Patient age: "); - int age = Integer.parseInt(scanner.nextLine()); - System.out.print("Patient gender: "); - String gender = scanner.nextLine(); - System.out.print("Patient address: "); - String address = scanner.nextLine(); - System.out.print("Patient phone number: "); - String phoneNumber = scanner.nextLine(); - - hospitalSystem.addPatientRecord(new Patient(name, age, gender, address, phoneNumber)); - } - - System.out.println("Enter appointment scheduling (date YYYY-MM-DD, patient name), type 'done' to finish:"); - while (true) { - System.out.print("Date (YYYY-MM-DD): "); - String dateString = scanner.nextLine(); - if (dateString.equals("done")) break; - System.out.print("Patient name: "); - String patientName = scanner.nextLine(); - - Date date = parseDate(dateString); - if (date != null) { - Patient patient = hospitalSystem.getPatientByName(patientName); - if (patient != null) { - hospitalSystem.scheduleAppointment(date, patient); - } else { - System.out.println("Patient not found."); - } - } else { - System.out.println("Invalid date format."); - } - } - - hospitalSystem.displayPatientRecords(); - hospitalSystem.displayAppointmentSchedule(); - - scanner.close(); - } - - private static Date parseDate(String dateString) { - try { - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - return dateFormat.parse(dateString); - } catch (ParseException e) { - System.out.println("Error parsing date: " + e.getMessage()); - return null; - } - } -} \ No newline at end of file From d0aec6c906e4332ddc05a431fd796daf110c40fb Mon Sep 17 00:00:00 2001 From: chittakushal <111438028+chittakushal@users.noreply.github.com> Date: Sat, 4 May 2024 19:54:46 +0530 Subject: [PATCH 4/4] Add files via upload --- chitta kushal/HospitalSystemDemo.java | 134 ++++++++++++++++++ chitta kushal/OnlineBankingSystemMain.java | 154 +++++++++++++++++++++ 2 files changed, 288 insertions(+) create mode 100644 chitta kushal/HospitalSystemDemo.java create mode 100644 chitta kushal/OnlineBankingSystemMain.java diff --git a/chitta kushal/HospitalSystemDemo.java b/chitta kushal/HospitalSystemDemo.java new file mode 100644 index 0000000..1eca880 --- /dev/null +++ b/chitta kushal/HospitalSystemDemo.java @@ -0,0 +1,134 @@ +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +class Patient { + private String name; + private int age; + private String gender; + private String address; + private String phoneNumber; + + public Patient(String name, int age, String gender, String address, String phoneNumber) { + this.name = name; + this.age = age; + this.gender = gender; + this.address = address; + this.phoneNumber = phoneNumber; + } + + public String getName() { + return name; + } + + @Override + public String toString() { + return "Name: " + name + ", Age: " + age + ", Gender: " + gender + ", Address: " + address + ", Phone: " + phoneNumber; + } +} + +class HospitalManagementSystem { + private List patientRecords; + private Map> appointmentSchedule; + + public HospitalManagementSystem() { + patientRecords = new ArrayList<>(); + appointmentSchedule = new HashMap<>(); + } + + public void addPatientRecord(Patient patient) { + patientRecords.add(patient); + } + + public void scheduleAppointment(Date date, Patient patient) { + appointmentSchedule.computeIfAbsent(date, k -> new ArrayList<>()).add(patient); + } + + public void displayPatientRecords() { + System.out.println("Patient Records:"); + for (Patient patient : patientRecords) { + System.out.println(patient); + } + } + + public void displayAppointmentSchedule() { + System.out.println("Appointment Schedule:"); + for (Map.Entry> entry : appointmentSchedule.entrySet()) { + System.out.println("Date: " + entry.getKey()); + System.out.println("Patients:"); + for (Patient patient : entry.getValue()) { + System.out.println(patient); + } + System.out.println(); + } + } + + public Patient getPatientByName(String name) { + for (Patient patient : patientRecords) { + if (patient.getName().equals(name)) { + return patient; + } + } + return null; + } +} + +public class HospitalSystemDemo { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + HospitalManagementSystem hospitalSystem = new HospitalManagementSystem(); + + System.out.println("Enter patient information (name, age, gender, address, phone), type 'done' to finish:"); + while (true) { + System.out.print("Patient name: "); + String name = scanner.nextLine(); + if (name.equals("done")) break; + System.out.print("Patient age: "); + int age = Integer.parseInt(scanner.nextLine()); + System.out.print("Patient gender: "); + String gender = scanner.nextLine(); + System.out.print("Patient address: "); + String address = scanner.nextLine(); + System.out.print("Patient phone number: "); + String phoneNumber = scanner.nextLine(); + + hospitalSystem.addPatientRecord(new Patient(name, age, gender, address, phoneNumber)); + } + + System.out.println("Enter appointment scheduling (date YYYY-MM-DD, patient name), type 'done' to finish:"); + while (true) { + System.out.print("Date (YYYY-MM-DD): "); + String dateString = scanner.nextLine(); + if (dateString.equals("done")) break; + System.out.print("Patient name: "); + String patientName = scanner.nextLine(); + + Date date = parseDate(dateString); + if (date != null) { + Patient patient = hospitalSystem.getPatientByName(patientName); + if (patient != null) { + hospitalSystem.scheduleAppointment(date, patient); + } else { + System.out.println("Patient not found."); + } + } else { + System.out.println("Invalid date format."); + } + } + + hospitalSystem.displayPatientRecords(); + hospitalSystem.displayAppointmentSchedule(); + + scanner.close(); + } + + private static Date parseDate(String dateString) { + try { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + return dateFormat.parse(dateString); + } catch (ParseException e) { + System.out.println("Error parsing date: " + e.getMessage()); + return null; + } + } +} \ No newline at end of file diff --git a/chitta kushal/OnlineBankingSystemMain.java b/chitta kushal/OnlineBankingSystemMain.java new file mode 100644 index 0000000..c10d1f5 --- /dev/null +++ b/chitta kushal/OnlineBankingSystemMain.java @@ -0,0 +1,154 @@ +import java.util.HashMap; +import java.util.Map; +import java.util.Scanner; + +class BankAccount { + private String accountNumber; + private double balance; + private Map transactionHistory; + + public BankAccount(String accountNumber, double initialBalance) { + this.accountNumber = accountNumber; + this.balance = initialBalance; + this.transactionHistory = new HashMap<>(); + } + + public void deposit(double amount) { + balance += amount; + transactionHistory.put("Deposit", amount); + } + + public boolean withdraw(double amount) { + if (balance >= amount) { + balance -= amount; + transactionHistory.put("Withdrawal", -amount); + return true; + } + return false; + } + + public double getBalance() { + return balance; + } + + public Map getTransactionHistory() { + return transactionHistory; + } +} + +class OnlineBankingSystem { + private Map accounts; + private Scanner scanner; + + public OnlineBankingSystem() { + accounts = new HashMap<>(); + scanner = new Scanner(System.in); + } + + public void createAccount() { + System.out.println("Enter account number:"); + String accountNumber = scanner.nextLine(); + System.out.println("Enter initial balance:"); + double initialBalance = scanner.nextDouble(); + scanner.nextLine(); // Consume newline + BankAccount account = new BankAccount(accountNumber, initialBalance); + accounts.put(accountNumber, account); + System.out.println("Account created successfully."); + } + + public void deposit() { + System.out.println("Enter account number:"); + String accountNumber = scanner.nextLine(); + BankAccount account = accounts.get(accountNumber); + if (account != null) { + System.out.println("Enter deposit amount:"); + double amount = scanner.nextDouble(); + scanner.nextLine(); // Consume newline + account.deposit(amount); + System.out.println("Deposit successful."); + } else { + System.out.println("Account not found."); + } + } + + public void withdraw() { + System.out.println("Enter account number:"); + String accountNumber = scanner.nextLine(); + BankAccount account = accounts.get(accountNumber); + if (account != null) { + System.out.println("Enter withdrawal amount:"); + double amount = scanner.nextDouble(); + scanner.nextLine(); // Consume newline + if (account.withdraw(amount)) { + System.out.println("Withdrawal successful."); + } else { + System.out.println("Insufficient balance."); + } + } else { + System.out.println("Account not found."); + } + } + + public void displayBalance() { + System.out.println("Enter account number:"); + String accountNumber = scanner.nextLine(); + BankAccount account = accounts.get(accountNumber); + if (account != null) { + System.out.println("Current balance: " + account.getBalance()); + } else { + System.out.println("Account not found."); + } + } + + public void displayTransactionHistory() { + System.out.println("Enter account number:"); + String accountNumber = scanner.nextLine(); + BankAccount account = accounts.get(accountNumber); + if (account != null) { + System.out.println("Transaction History:"); + Map history = account.getTransactionHistory(); + for (Map.Entry entry : history.entrySet()) { + System.out.println(entry.getKey() + ": " + entry.getValue()); + } + } else { + System.out.println("Account not found."); + } + } +} + +public class OnlineBankingSystemMain { + public static void main(String[] args) { + OnlineBankingSystem bankingSystem = new OnlineBankingSystem(); + Scanner scanner = new Scanner(System.in); + + while (true) { + System.out.println("\n1. Create Account\n2. Deposit\n3. Withdraw\n4. Display Balance\n5. Display Transaction History\n6. Exit\n"); + System.out.println("Enter your choice:"); + int choice = scanner.nextInt(); + scanner.nextLine(); + switch (choice) { + case 1: + bankingSystem.createAccount(); + break; + case 2: + bankingSystem.deposit(); + break; + case 3: + bankingSystem.withdraw(); + break; + case 4: + bankingSystem.displayBalance(); + break; + case 5: + bankingSystem.displayTransactionHistory(); + break; + case 6: + System.out.println("Exiting..."); + scanner.close(); + System.exit(0); + default: + System.out.println("Invalid choice. Please enter a number from 1 to 6."); + } + } + } +}