Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Make sure to put the main section of your code in the following if block: (1) Bu

ID: 3707453 • Letter: M

Question

Make sure to put the main section of your code in the following if block:

(1) Build the Account class with the following specifications:

Attributes

name (str)

account_number (int)

balance (float)

Create a constructor that has 3 parameters (in addition to self) that will be passed in from the user. (no default values)

Define a __str__() method to print an Account like the following

Define a deposit() method that has 1 parameter (in addition to self) that will be passed in from the user. (no default values) The method deposits the specified amount in the account.

Define a withdraw() method that has 2 parameters (in addition to self) that will be passed in from the user. (no default values) The method withdraws the specified amount (1st parameter) and fee (2nd parameter) from the account.

(2) In the main section of your code, create 3 accounts.

Trish Duce 90453889 100

Donald Duck 83504837 100

Joe Smith 74773321 100

(3) Print the 3 accounts using print(acct1)…

(4) Deposit 25.85, 75.50 and 50 into accounts 1, 2 and 3.

(5) Print the 3 accounts.

(6) Withdraw 25.85 (2.50 fee), 75.50 (1.50 fee), 50.00 (2.00 fee).

(7) Print the 3 accounts.

Output should look like the following:

Account Name: Trish Duce

Account Number: 90453889

Account Balance: $100.00

Account Name: Donald Duck

Account Number: 83504837

Account Balance: $100.00

Account Name: Joe Smith

Account Number: 74773321

Account Balance: $100.00

Account Name: Trish Duce

Account Number: 90453889

Account Balance: $125.85

Account Name: Donald Duck

Account Number: 83504837

Account Balance: $175.50

Account Name: Joe Smith

Account Number: 74773321

Account Balance: $150.00

Account Name: Trish Duce

Account Number: 90453889

Account Balance: $97.50

Account Name: Donald Duck

Account Number: 83504837

Account Balance: $98.50

Account Name: Joe Smith

Account Number: 74773321

Account Balance: $98.00

Explanation / Answer

PROGRAM

class Account: # Create class Account

def __init__(self,name,ano,bal): # Create 3 parameterised constructor
# assign parameters itself
self.name=name
self.ano=ano
self.bal=bal

def __str__(self): # display account information using print statement
return 'Account Name: %s Account Number: %d Account Balance: $%.2f ' %(self.name,self.ano,self.bal)

def deposit(self,dep): # Create and implement deposit() function with single parameter dep
self.bal=self.bal+dep # calculate actual balance after deposit in bal
return self.bal # return actual balance amount

def withdraw(self,amt,fee): # Create and implement withdraw() function with two paratemers amt and fee
self.bal=self.bal-(amt+fee) # calculate actual balance after withdrawal in bal
return self.bal # return actual balance after withdrawal


if __name__ == "__main__": # create main
acct1=Account("Trish Duce",90453889,100) # create object acct1
acct2=Account("Donald Duck",83504837,100) # create object acct2
acct3=Account("Joe Smith",74773321,100) # create object acct3
# print actual information of 3 objects
print(acct1)
print(acct2)
print(acct3)
# calling deposit() method of 3 objects
acct1.deposit(25.85)
acct2.deposit(75.50)
acct3.deposit(50)
# print after deposit the balance amount of 3 objects
print(acct1)
print(acct2)
print(acct3)
# calling withdraw() method of 3 objects
acct1.withdraw(25.85,2.50)
acct2.withdraw(75.50,1.50)
acct3.withdraw(50.00,2.00)
# print after withdrawal the balance amount of 3 objects
print(acct1)
print(acct2)
print(acct3)

  
  
OUTPUT   


  

Account Name: Trish Duce
Account Number: 90453889
Account Balance: $100.00

Account Name: Donald Duck
Account Number: 83504837
Account Balance: $100.00

Account Name: Joe Smith
Account Number: 74773321
Account Balance: $100.00

Account Name: Trish Duce
Account Number: 90453889
Account Balance: $125.85

Account Name: Donald Duck
Account Number: 83504837
Account Balance: $175.50

Account Name: Joe Smith
Account Number: 74773321
Account Balance: $150.00

Account Name: Trish Duce
Account Number: 90453889
Account Balance: $97.50

Account Name: Donald Duck
Account Number: 83504837
Account Balance: $98.50

Account Name: Joe Smith
Account Number: 74773321
Account Balance: $98.00

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote