Question

In: Computer Science

Using Python You just started your summer internship with NU Bank as part of its growing...

Using Python

You just started your summer internship with NU Bank as part of its growing development team. Your first assignment is to design and build two classes that are to be utilized in both the banks website and internal applications. The first is a loan class representing a loan contract. The second is a customer class representing the individual receiving the loan. You will be building the business logic classes, so you don’t have to worry about forms for communicating with the user or data access classes to communicate with the database. To test your classes, you will use them in a test application. The requirements for your classes and the testing application are as follows:

  • You are to design and build 2 components of the Loan Processing System (LPS). There will be one class to represent loan contracts, and another to represent customers.

  • Each class should have at least 2 members and 2 methods.

  • The LPS will need to be able to check that the customer is at least 21 years old. A method

    (IsEligible) should return true if the customer is 21 or older and false otherwise. An associated

    method (GetAge) should return the customer’s age in years.

  • When assigning the customer to the loan, the assignment should be rejected if the customer is

    ineligible based on age.

  • The following pieces of information about each business object are important to track:

    o Customer:
    ▪ Customer ID, First Name, Last Name, Email, Phone, Date of Birth

    o Loan:
    ▪ Loan ID, Agent Name, Loan Amount, Interest Rate, Customer

  • For purposes of testing, you will write a small application

o Gather information you need about the Customer via console input
o Any information you need about the Loan can be hard-coded using the constructor

(__init__) or properties of the class
o The application must do the following – utilizing instances of your classes:

  • ▪ Ask the user for any needed information

  • ▪ Allow the user to save information to the Customer object.

  • ▪ Allow the user to retrieve information from the Customer object.

  • ▪ Test the ‘IsEligible’ functionality and output the customer age, along with the

    loan information, if the assignment of the customer to the loan succeeds.

Solutions

Expert Solution

EXPLANATION:

  • all of the functionalities are completed with 2 classes having remembered all the requirements.
  • The function GetAge() uses datetime module of python to get the current date and then calculating the actual age of the customer.
  • the IsEligible function gets the age and then verifying if customer is eligible or not.

NOTE: IN CASE OF ANY DOUBT , ASK IN THE COMMENTS

CODE:

import datetime


class Loan:
   loans = 0
   def __init__(self,customer):
       Loan.loans +=1
       self.loanId = "L0" + str(Loan.loans)
       self.agent = "XYZ"
       self.LoanAmount = 0
       self.intRate = 10
       self.customer = customer

   def setLoanAmt(self, amount):
       self.LoanAmount = amount


   def IsEligible(self, customer):
      
       custAge = customer.GetAge()

       if custAge >= 21:
           return True

       return False


class Customer:

   def __init__(self):
       self.firstName = ""
       self.lastName = ""
       self.email = ""
       self.dob = ""


   def GetAge(self):
       if self.dob == "":
           print("Date of birth not given")
           return

       currentTime = datetime.datetime.today()

       currentYear = int(currentTime.year)
       currentMonth = int(currentTime.month)
       currentDay = int(currentTime.day)

       # customer dob
       custDay = int(self.dob[:2])
       custMonth = int(self.dob[3:5])
       custYear = int(self.dob[6:11])

      

       # getting age
       age = currentYear - custYear
       if custMonth > currentMonth:
           age -= 1
       elif custMonth == currentMonth and custDay > currentDay:
           age -= 1


       return age

if __name__ == "__main__":

   print("Welcome to the NU Bank! \nEnter your details below to apply for loan")

   customer = Customer()

   firstName = input("Enter your first name: ")
   lastName = input("Enter your last name: ")
   email = input("Enter email: ")
   dob = input("Enter Date of birth in format (dd-mm-yyyy):")

   customer.first = firstName
   customer.last = lastName
   customer.email = email
   customer.dob = dob

   age = customer.GetAge()
  

   loan = Loan(customer)

   loanAmt = int(input("Enter the amount you want in Loan: "))
   loan.setLoanAmt(loanAmt)

   if loan.IsEligible(customer):
       print("Congratulations! Your loan has been sanctioned")
       print("Your age is eligible for this loan , your age is: ", age)
       print("Your loan ID:", loan.loanId)
       print("Your loan agent: ", loan.agent)
       print("Your loan amount: ", loan.LoanAmount)
       print("Interest Rate: ", loan.intRate)
   else:
       print("Sorry your age is below eligibility criteria")
       print("Your age is:", age)

SCREENSHOTS:


Related Solutions

You have just started your summer? internship, and your boss asks you to review a recent...
You have just started your summer? internship, and your boss asks you to review a recent analysis that was done to compare three alternative proposals to enhance the? firm's manufacturing facility. You find that the prior analysis ranked the proposals according to their? IRR, and recommended the highest IRR? option, Proposal A. You are concerned and decide to redo the analysis using NPV to determine whether this recommendation was appropriate. But while you are confident the IRRs were computed? correctly,...
You have just started your summer internship, and your boss asks you to review a recent...
You have just started your summer internship, and your boss asks you to review a recent analysis that was done to compare three alternative proposals to enhance the firm's manufacturing facility. You find that the prior analysis ranked the proposals according to their IRR and recommended the highest IRR option, Proposal A. You are concerned and decide to redo the analysis using NPV to determine whether this recommendation was appropriate. But while you are confident the IRRs were computed correctly,...
You just started an internship working in a small business that is in its second year...
You just started an internship working in a small business that is in its second year of operation. The business owner wants to apply for a bank loan as soon as possible, and is very anxious to receive the second year financial statements. The business owner has observed you performing the steps in the recording process of journalizing, posting and preparing a trial balance, and he doesn't understand why you can't prepare the financial statements without first preparing adjusting entries...
You have just landed your dream summer internship, and your boss asks you to analyze a...
You have just landed your dream summer internship, and your boss asks you to analyze a project that has an investment cost of $2,000,000, to be paid today (t = 0), and will generate a cash-flow of $200,000 in the first year (t = 1). The cash-flow will then grow at 10% per year for the next six years (the last time the cash-flow grows at 10% is from t = 6 to t = 7). Afterwards, as competition increases,...
You have just landed your dream summer internship, and your boss asks you to analyze a...
You have just landed your dream summer internship, and your boss asks you to analyze a project that has an investment cost of 3,500,000, to be paid today (t = 0), and will generate a cash-flow of 350,000 in the first year (t = 1). The cash-flow will then grow at 12% per year for the next eight years (the last time the cash-flow grows at 12% is from t = 8 to t = 9). Afterwards, as competition increases,...
You have just passed ACST1001 and started a summer internship at Harrison Bank, with Peter as your supervisor. As your first task, Peter has given you some client accounts and asked you to verify some of the details.
You have just passed ACST1001 and started a summer internship at Harrison Bank, with Peter as your supervisor. As your first task, Peter has given you some client accounts and asked you to verify some of the details.The first file is for a client named Mary, who has a mortgage with the bank. You go through the file and note the following information for Mary's mortgageInitial loan: $640,000Term of loan: 25 yearsRepayment frequency. End of each fortnightInterest rate on loan:...
You have just begun your summer internship at Tmedic. The company supplies sterilized surgical instruments for...
You have just begun your summer internship at Tmedic. The company supplies sterilized surgical instruments for physicians. To expand sales, Tmedic is considering paying a commission to its sales force. The controller, Jane Hewitt, asks you to compute (1) the new breakeven sales figure and (2) the operating profit if sales increase 15% under the new sales commission plan. She thinks you can handle this task because you learned CVP analysis in your accounting class.                 You spend the next...
You have just started an internship with Frode Laursen and you have spent your first day...
You have just started an internship with Frode Laursen and you have spent your first day together with a Key Account Manager (KAM), who handles transactions with three different customer segments (A, B and C). He proudly tells you that his focus is on serving the A customers since they yield the highest contribution margin per transaction. Then come the B customers, and if there is time left, he also serves the C customers. Upfront, his argument sounds logical, but...
You apply for a summer internship with a startup company, and your chance of getting an...
You apply for a summer internship with a startup company, and your chance of getting an offer is 80% if you well prepare for an interview. Otherwise, you will only get 20% chance for an offer. Suppose that the likelihood of your preparation going well is 30%. What is the probability that you get the internship?
You have an internship this summer for the Cook County Department of Public Health. Your job...
You have an internship this summer for the Cook County Department of Public Health. Your job is to work with the West Nile Virus group. You need to identify possible reservoirs, vectors, and determine how many people have been infected this year. Discuss which three types of organisms you will be examining and why.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT