Page 102 - CITS - CSA - TP (Volume 2) - Hindi
P. 102

कं  ूटर सॉ वेयर ए ीके शन - 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();

                  }
              }

           आउटपुट:






















                                                           88

                                   CITS : IT & ITES - कं  ूटर सॉ वेयर ए ीके शन - अ ास 94
   97   98   99   100   101   102   103   104   105   106   107