QuestionQuestion

Problem 1
Write a program that prompts the user to enter 5 numbers. The numbers must be entered as a comma separated list ( e.g. 4, 5, -2, 3, 7). The program must calculate and output the average, the largest, and smallest the user entered. The program must also determine if the numbers are entered in ascending, descending order, or out of order. You must use functions to complete the work. Define the functions listed below in your program.

getAverage

getLargest

getSmallest

isOrdered

Problem 2
In this project your will create a simple bank applications that creates accounts for customers and performs simple actions such as deposit, withdraw, and applying annual interest. The objective is to use object oriented programming and inheritance in the program.

You shall define a 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.

You shall 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 shall define 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).

You can use the “main” shown below to test your 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

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

L = [float(i) for i in input(
    'Please enter 5 numbers separated by comma: ').split(',')]


def getAverage(L):
    return sum(L) / len(L)


def getLargest(L):
    return max(L)


def getSmallest(L):
    return min(L)


def isOrdered(L):
    order = 'Numbers are out of order.'
    if L == sorted(L, reverse=True):
       order = 'Numbers are in descending order.'
    elif L == sorted(L):
       order = 'Numbers are in ascending order order.'
    return order...

By purchasing this solution you'll be able to access the following files:
Solution1.py and Solution2.py.

$15.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats