Page 103 - CTS - CSA TP - Volume 2
P. 103

COMPUTER SOFTWARE APPLICATION - CITS




                      if (balance >= amount) {
                          balance -= amount;
                          System.out.println(amount + “ withdrawn successfully.”);
                      } else {

                          System.out.println(“Insufficient funds.”);
                      }
                  }
                  // Method to display account information

                  void displayAccountInfo() {
                      System.out.println(“Account Number: “ + accountNumber);
                      System.out.println(“Balance: $” + balance);
                  }
              }

              public class BankAccountDemo {
                  public static void main(String[] args) {
                      // Create an object of BankAccount class
                      BankAccount account1 = new BankAccount(“123456789”, 1000.0);

                      // Deposit and withdraw operations
                      account1.deposit(500.0);
                      account1.withdraw(200.0);
                      // Display account information
                      account1.displayAccountInfo();
                  }

              }
           Output:


































                                                           88

                               CITS : IT & ITES - Computer Software Application - Exercise 94
   98   99   100   101   102   103   104   105   106   107   108