Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON. Please DO NOT copy the answer from another website or from another question posted here. Original answers only. I will check the code for

PYTHON. Please DO NOT copy the answer from another website or from another question posted here. Original answers only. I will check the code for plagiarism.

Your task is to create a BankAccount class.

Class name BankAccount

Attributes __balance float

__pin integer

Methods __init_()

get_pin()

check_pin()

deposit()

withdraw()

get_balance()

The bank account will be protected by a 4-digit pin number (i.e. between 1000 and 9999). The pin should be generated randomly when the account object is created. The initial balance should be 0.

get_pin()should return the pin.

check_pin(pin) should check the argument against the saved pin and return True if it matches, False if it does not.

deposit(amount) should receive the amount as the argument, add the amount to the account and return the new balance

withraw(amount) should check if the amount can be withdrawn (not more than is in the account), If so, remove the argument amount from the account and return the new balance if the transaction was successful. Return False if it was not.

get_balance() should return the current balance.

Finally, write a main() to demo your bank account class. Present a menu offering a few actions and perform the action the user requests, checking the pin where appropriate.

1. New Account - if selected, create a new account and tell the user the pin.

2. Deposit - if selected, prompt the user to input the pin, check the pin and then, if correct, prompt for the amount to deposit. Process the deposit and report the new balance

3. Withdraw - if selected, prompt the user to input the pin, check the pin and then, if correct, prompt for the amount to withdraw. Process the withdrawal and report the new balance or a message if the transaction was not successful.

4. Check balance - if selected, prompt the user to input the pin, check the pin and then, if correct, call the get_balance method and report the balance.

All printed output should be done in main(), not the methods.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions