हिंदी

A bank is a financial institution that is involved in borrowing and lending money. With advancements in technology, online banking, also known as internet banking allows customers of a bank - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

A bank is a financial institution that is involved in borrowing and lending money. With advancements in technology, online banking, also known as internet banking allows customers of a bank to conduct a range of financial transactions through the bank’s website anytime, anywhere. As part of the initial investigation, you are suggested to

  • collect a bank application form. After careful analysis of the form, identify the information required for opening a savings account. Also, enquire about the rate of interest offered for a saving account.
  • The basic two operations performed on an account are Deposit and Withdrawal. Write a menu-driven program that accepts either of the two choices of Deposit and Withdrawal, then accepts an amount, performs the transaction, and accordingly displays the balance. Remember, every bank has a requirement for a minimum balance which needs to be taken care of during withdrawal operations. Enquire about the minimum balance required in your bank.
  • Collect the interest rates for opening a fixed deposit in various slabs in a savings bank account. Remember, rates may be different for senior citizens.

Finally, write a menu-driven program having the following options (use functions and appropriate data types):

  • Open a savings bank account
  • Deposit money
  • Withdraw money
  • Take details, such as the amount and period for a Fixed Deposit, and display its maturity amount for a particular customer.
कोड लेखन
Advertisements

उत्तर

# Menu-driven banking program
class BankAccount:
    def __init__(self, account_number, name, balance, min_balance):
        self.account_number = account_number
        self.name = name
        self.balance = balance
        self.min_balance = min_balance

    def deposit(self, amount):
        self.balance += amount
        print(f"Amount deposited: {amount}. New balance: {self.balance}")

    def withdraw(self, amount):
        if self.balance - amount < self.min_balance:
            print("Insufficient balance to perform this withdrawal while maintaining the minimum balance.")
        else:
            self.balance -= amount
            print(f"Amount withdrawn: {amount}. New balance: {self.balance}")

def calculate_fixed_deposit(amount, rate, period):
    # Simple interest formula for maturity amount
    maturity_amount = amount + (amount * rate * period / 100)
    return maturity_amount

def main():
    print("Welcome to the Bank Menu")
    account = None  # Placeholder for the account object
    min_balance = 1000  # Example minimum balance requirement
    
    while True:
        print("\nChoose an option:")
        print("1. Open a savings bank account")
        print("2. Deposit money")
        print("3. Withdraw money")
        print("4. Fixed Deposit details and maturity calculation")
        print("5. Exit")

        choice = int(input("Enter your choice: "))

        if choice == 1:
            account_number = input("Enter account number: ")
            name = input("Enter account holder name: ")
            balance = float(input("Enter initial deposit amount: "))
            account = BankAccount(account_number, name, balance, min_balance)
            print("Savings account created successfully.")

        elif choice == 2:
            if account:
                amount = float(input("Enter amount to deposit: "))
                account.deposit(amount)
            else:
                print("Please open an account first.")

        elif choice == 3:
            if account:
                amount = float(input("Enter amount to withdraw: "))
                account.withdraw(amount)
            else:
                print("Please open an account first.")

        elif choice == 4:
            if account:
                amount = float(input("Enter the amount for fixed deposit: "))
                period = float(input("Enter the period in years: "))
                rate = float(input("Enter the interest rate (in %): "))
                maturity_amount = calculate_fixed_deposit(amount, rate, period)
                print(f"The maturity amount after {period} years is: {maturity_amount}")
            else:
                print("Please open an account first.")

        elif choice == 5:
            print("Thank you for using the banking system. Goodbye!")
            break

        else:
            print("Invalid choice. Please select a valid option.")

if __name__ == "__main__":
    main()
shaalaa.com
Concepts of Tuples in Python
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 10: Tuples and Dictionaries - Exercise [पृष्ठ २२६]

APPEARS IN

एनसीईआरटी Computer Science [English] Class 11
अध्याय 10 Tuples and Dictionaries
Exercise | Q 1. | पृष्ठ २२६
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×