Define customer class in which a customer has a first name

Assignment Help Python Programming
Reference no: EM132361108

Question

Define Customer class. A customer has a first name, last name, and social security number. You must override __str__ operator to return the customer first name, last name and ssn.

Define a BankAccount base class. A BankAccount has a customer, account number, and a balance. A bank account can be opened with any amount of initial deposit.

For each bank account, a 10 digit random account number must be created.

Bank account has the following methods: deposit, withdraw. applyAnnualInterest.

Note that the amount withdrawn cannot exceed the balance. If it does, the amount should not be withdrawn and insufficient funds should be reported.

You must override __str__ operator to return a pretty string representation of a bank account.

You shall define two types of account subclasses: Checking Account and Saving Account.

These subclasses inherit from the BankAccount base class.

Each account accrues interest. A saving account accrues 5% fixed interest and a checking account accrues 2% for any amount in excess of $10000 (For example, if there is $11000 in the checking account, the interest is only applied to $1000).

The "main" shown below can be used to test the application. The expected output is also provided.

def main():

alin = Customer('Alin', 'Smith', '111-11-1111')

mary = Customer('Mary', 'Lee', '222-22-2222')

alinAccnt = CheckingAccount(alin)

maryAccnt = SavingAccount(mary)

alinAccnt.deposit(20000)

print(alinAccnt)

alinAccnt.withdraw(5000)

print(alinAccnt)

alinAccnt.applyAnnualInterest()

print(alinAccnt)

maryAccnt.deposit(10000)

print(maryAccnt)

maryAccnt.withdraw(15000)

print(maryAccnt)

maryAccnt.applyAnnualInterest()

print(maryAccnt)

=================== This is the expected output =======================

Alin Smith (ssn: 111-11-1111) , account number 1702660396, balance $20000

Alin Smith (ssn: 111-11-1111) , account number 1702660396, balance $15000

Alin Smith (ssn: 111-11-1111) , account number 1702660396, balance $15100.0

Mary Lee (ssn: 222-22-2222) , account number 2552619508, balance $10000

Mary Lee (ssn: 222-22-2222) , insufficent funds to withdraw $ 15000

Mary Lee (ssn: 222-22-2222) , account number 2552619508, balance $10000

Mary Lee (ssn: 222-22-2222) , account number 2552619508, balance $10500.0

You have coded it as below but I'm having trouble trying to test the below code and get above output. Please review your code and let you know how you can test the below code to get the above expected output?

class Customer:

def __init__(self,firstName, lastName, ssn):

self.firstName = firstName

self.lastName = lastName

self.ssn = ssn

def setfirstName(self,firstName):

self.firstName = firstName

def setlastName(self,lastName):

self.lastName = lastName

def __str__(self):

self.name = "{},{} (SSN:{})".format(self.firstName, self.lastName,self.ssn)

return self.name

class BankAccount(Customer):

def __init__(self,customer,balance = 0):

from random import randint

n = 10

range_start = 10**(n-1)

range_end = (10**n)-1

accountNumber = randint(range_start, range_end)

self.customer = customer

self.balance = balance

self.accountNumber = randint(self.range_start, self.range_end)

def setCustomer(self,customer,accountNumber):

self.customer = customer

self.accountNumber = accountNumber

def getCustomer(self,customer,accountNumber):

return self.customer, self.accountNumber

def __str__(self):

customer = "{} account number: {}, balance: ${}".format(self.customer,self.accountNumber,self.balance)

return customer

Reference no: EM132361108

Questions Cloud

Identify and evaluate control measures for ivas : Can someone provide two examples of possible adversarial attacks involving Intelligent Virtual Assistant that may target or involve data confidentiality
Examples of possible adversarial attacks : What are two examples of possible adversarial attacks that may target or involve IVAs and what are some good control measures that are likely to best address
Increasingly intelligent and adaptive machines : What are security risks of IVA's and how are the risks enhanced as conversations between people and increasingly intelligent and adaptive machines
Script should display the message : Print a "Thank You" Message on a new line: Before stopping, the script should display the message Thank you followed
Define customer class in which a customer has a first name : Define Customer class. A customer has a first name, last name, and social security number. You must override __str__ operator to return the customer first name.
Explain how you developed your educational program : Create an educational program, event, or piece of literature (for example, a pamphlet) that incorporates best practices in health promotion and disease.
What new or current threats or viruses : What new or current threats or viruses do you know of? What is their method of infection?
Array parameter in the invocation of a function : Discuss the important characteristics we need to be aware of when using an array parameter in the invocation of a function.
Conduct a health assessment of a population of your choice : Conduct a health assessment of a population of your choice as you complete the following: Describe the key elements that make up a health assessment at each.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd