Knowee
Questions
Features
Study Tools

A program to simulate a simple banking system in which the initial balance and rate of interest are read from the keyboard and these values are initialised using the constructor member function. The program consists of the following methods:To initialise the balance amount and the rate of interest using constructor member functionTo make depositTo withdraw an amount for the balanceTo find compound interest based on the rate of interestTo know the balance amountTo display the menu options

Question

A program to simulate a simple banking system in which the initial balance and rate of interest are read from the keyboard and these values are initialised using the constructor member function. The program consists of the following methods:To initialise the balance amount and the rate of interest using constructor member functionTo make depositTo withdraw an amount for the balanceTo find compound interest based on the rate of interestTo know the balance amountTo display the menu options

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple Python program that simulates a basic banking system:

class BankAccount:
    def __init__(self, balance, interest_rate):
        self.balance = balance
        self.interest_rate = interest_rate

    def deposit(self, amount):
        self.balance += amount
        return self.balance

    def withdraw(self, amount):
        if amount > self.balance:
            print("Insufficient funds")
        else:
            self.balance -= amount
        return self.balance

    def compound_interest(self):
        self.balance = self.balance * (1 + self.interest_rate)
        return self.balance

    def get_balance(self):
        return self.balance

    def display_menu(self):
        print("1. Deposit")
        print("2. Withdraw")
        print("3. Calculate compound interest")
        print("4. Check balance")
        print("5. Exit")

def main():
    balance = float(input("Enter initial balance: "))
    interest_rate = float(input("Enter interest rate: "))
    account = BankAccount(balance, interest_rate)

    while True:
        account.display_menu()
        choice = int(input("Enter your choice: "))

        if choice == 1:
            amount = float(input("Enter amount to deposit: "))
            account.deposit(amount)
        elif choice == 2:
            amount = float(input("Enter amount to withdraw: "))
            account.withdraw(amount)
        elif choice == 3:
            account.compound_interest()
        elif choice == 4:
            print("Current balance: ", account.get_balance())
        elif choice == 5:
            break
        else:
            print("Invalid choice. Please choose a valid option.")

if __name__ == "__main__":
    main()

This program creates a BankAccount class with methods for depositing, withdrawing, calculating compound interest, checking the balance, and displaying a menu. The main function initializes a BankAccount object with user input for the initial balance and interest rate, then enters a loop where the user can choose to deposit, withdraw, calculate compound interest, check the balance, or exit the program.

This problem has been solved

Similar Questions

Write a C++ program to implement a class called BankAccount that represents a simple bank account. The class should have private member variables for account number and balance. Include member functions to deposit and withdraw money from the account.Testcase:Input:Rs.1000.0  // initial balanceRs.500.0  // depositRs.200.0   // withdrawOutput:Rs.1300.0  // final balance Input:Rs.2000.0  // initial balanceRs.1000.0  // depositRs.4000.0   // withdrawOutput:NA  // final balance

Write a C++ program to implement a class called Bank that has private member variables for account_number, operation_type,old_balance , amount, and  new_balance.Create a parameterized constructor to initialize the data members.Include member function “calculate “that prints the balance after deposit or withdrawal.Sample output1011 (account number)D  (D-deposit / W-withdraw)1000 (old balance)2000 (amount)Sample Output3000

Program that creates a class Account that stores a variable balance. The class has methods to startaccount, to deposit money, to withdraw money and tell the current balance amoun

Write a java program to create a bank account with Name of the account holder, type of account(savings or  current), Account number and Balance amount in the account. Also, create 5 customers for the class Bank_account using array of objects. Access the customers to perform credit, debit and display of balance.Input 1:Enter the customers:ReenaSavings1231000RobinCurrent4562000PraveenSavings7893000SherinCurrent2342500DeenaSavings5672000Enter choice:1. Credit2. Debit Output :ReenaSavings1232000

Write a program to create a bank customer information using array of structures, nested structures and functions.First structure should hold the following information: Customer personal details: Name, Gender, Account Number, DOB; Second structure should hold the following information: Customer account details: Type of account, opening balance, closing balance

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.