Question

In: Computer Science

MUST BE PYTHON 3 Instructions: The following programming problem can be solved by a program that...

MUST BE PYTHON 3

Instructions: The following programming problem can be solved by a program that performs three basic tasks (Input Data, Process Data, Output Results) along with selection and repetition coding techniques.

Problem Statement

A finance company provides loans for motorcycles at different rates depending on how much the total loan amount is and how many payments will be made on the loan. Using the information in the table below, write a program that will calculate the monthly payment based on user inputs of loan amount and number of monthly payments. The user will NOT input the percentage rate, as this will be determined by the program code based on user input of loan amount and number of payments. The output will display the loan amount, the number of payments, monthly payments and the interest rate of the loan.

Problem Statement
Amount of Loan # of Payments Interest Rate Applied
$500 - $ 2,500 6-12 8%
13-36 10%
37-48 12%
$2,501 - $10,000 6-12 7%
13-36 8%
37-48 6%
$10,001 or above 6-12 5%
13-36 6%
37-48 7%


If the user enters data that is "out of bounds" (loan amount/number of payments below or above minimum/maximum in the table), display an error message explaining the situation to the user and ask for the loan amount or number of payments (whichever one was out of bounds) again. Message Example: "We do not finance loans below $500."

You MUST use Modular Programming techniques by using functions in your program. Your "main" module should not be very large.

Other Requirements:

  • Documentation: Incorporate programming style as described here: "Python Style Guide"
  • Test and debug your Program: Create sample input data, run the program, then check your answers with a calculator or Excel. If something did not match up, then fix your program.
  • Program must execute and produce correct output.
  • Read this page again to be sure you covered all requirements.
  • See the Programming Project Rubric for grading principles.
  • Your name and desired profession should be at the top of each output data file.
  • Column data should be neatly aligned.
  • Columns should have heading titles.
  • Loan payment formula suggested, located:   [http://financeformulas.net/Loan_Payment_Formula.html] . You may use other sources which are algebraically correct.

Submission Instructions:

  • Provide one enhancement, addition or improvement to the code. Provide comments to document this enhancement.
  • Save as filename: LastName_ProgProj_2.py.
  • Also, save a screenshot of a successful run for each program and save as: LastName_Chap_y_x.png. (y = chapter number, x = exercise number.)Upload files individually here. (Do not upload files unless they run successfully.)
  • Upload files here. (Do not upload files unless they run successfully.)

Solutions

Expert Solution

def print_all(amount,no_of_payments,payment,rate):
  headers=["Loan Amount","Number of Payments","Monthly Payments","Interest Rate"]
  data=[[amount,no_of_payments,payment,rate]]
  print (tabulate(data, headers))


def MonthlyPayment(amount,no_of_payments):
  if amount<500:
    print("We do not finance loans below $500.")
    return 0
  elif no_of_payments<6 or no_of_payments>48:
    print("We do not finance loans for this period.")
    return 0
  else:
    if amount>=500 and amount<=2500:
      if no_of_payments>=6 and no_of_payments<=12:
        rate=8
      elif no_of_payments>=13 and no_of_payments<=36:
        rate=10
      elif no_of_payments>=6 and no_of_payments<=12:
        rate=12
    elif amount>2500 and amount<=10000:
      if no_of_payments>=6 and no_of_payments<=12:
        rate=7
      elif no_of_payments>=13 and no_of_payments<=36:
        rate=8
      elif no_of_payments>=6 and no_of_payments<=12:
        rate=6
    else:
      if no_of_payments>=6 and no_of_payments<=12:
        rate=5
      elif no_of_payments>=13 and no_of_payments<=36:
        rate=6
      elif no_of_payments>=6 and no_of_payments<=12:
        rate=7

    payment=round(((rate*amount)/(1-((1+(rate/100))**-no_of_payments)))/100,2)
    print_all(amount,no_of_payments,payment,rate)

#Main Function
#enhanced the program for running it the no of times user wants it to run
from tabulate import tabulate
n=int(input("Enter the number of customers:"))
for i in range(n):
  amount=int(input("Enter the loan amount:"))
  no_of_payments=int(input("Enter the number of monthly payments:"))
  MonthlyPayment(amount,no_of_payments)

OUTPUT:


Related Solutions

This task is solved in Python 3. Develop a program that can change the phone number...
This task is solved in Python 3. Develop a program that can change the phone number of a person in phone.txt (hint: the easiest thing is probably to make a new version of the file, and then delete the old one before the new is renamed to phone.txt) Name: John Old phone number: 99776612 New number: 99889999 >>> phone.txt Replaced by ------> phone.txt Mary 98654321 June 99776655 Chris 99112233 Viv 98554455 John 99776612 Joe 97888776 Rick 99455443 Susan 98122134 Jill...
This task is solved in Python 3. Develop a program that can, among other things, manage...
This task is solved in Python 3. Develop a program that can, among other things, manage your courses and course results. It must also be able to calculate the average grade, for all grades or for a selection of grades limited to a certain subject area and / or course level (100, 200 or 300 level). NB! All courses are worth the same amount of credits. The program should have two global collections Courses is a list that contains the...
Python programming: Instructions: The python program should respond to user input on a command line Below...
Python programming: Instructions: The python program should respond to user input on a command line Below are the four options - if the user input is A, the program will quit -if the user input is B, the program will display the number of times the prompt has been displayed -if the user input is C, will display whatever is stored. -if the user inputs something else, it will store that user input as a string and append it to...
Using Python Programming PROBLEM 3 - OLD MACDONALD: Write a program to print the lyrics of...
Using Python Programming PROBLEM 3 - OLD MACDONALD: Write a program to print the lyrics of the song ”Old MacDonald”. Your program should print the lyrics using five different animals (i.e., cow, sheep, dog, cat ,turkey) using the example verse below. For this problem you are required to write then make use of a function getVerse that takes two string parameters: (1) the name of an animal and (2) the sound that animal makes. The function should not print anything...
This task is solved in Python 3. Develop a program that lets the user add new...
This task is solved in Python 3. Develop a program that lets the user add new people to the file phone.txt Add name and number, end with <enter> Name and number: Robin 94567402 Name and number: Jessica 99468283 Name and number: >>> Phone.txt Expanded to ------> Phone.txt Mary 98654321 June 99776655 Chris 99112233 Viv 98554455 John 99776612 Joe 97888776 Rick 99455443 Susan 98122134 Jill 99655732 Bob 98787896 Mary 98654321 June 99776655 Chris 99112233 Viv 98554455 John 99776612 Joe 97888776 Rick...
A program must execute 1012 instructions to solve a problem. A single processor system can solve...
A program must execute 1012 instructions to solve a problem. A single processor system can solve the problem in 106 seconds. Thus on average the single processor system executes 106 or 1-million instructions per second. We have a new program that has been parallelized for execution on a distributed-memory system. This parallel program uses (p) processors. Here each processor will execute 1012/p instructions and each processor must send 109(p-1) messages. We will assume there is not additional overhead for the...
USING C PROGRAMMING ***CODE MUST BE MODULARIZED** Instructions: Create a program that will collect multiple receipts...
USING C PROGRAMMING ***CODE MUST BE MODULARIZED** Instructions: Create a program that will collect multiple receipts from multiple classrooms to accumulate total cookie sales.   Once all receipts have been processed, the program must show what classroom is won and the total amount of cookies they sold. The classrooms that are participating are from the:                 2nd Floor: 201, 202, 203, 204, 205, 206, 207, 208                 3rd Floor: 301,302, 303, 304, 305, 306, 307, 308, 309                 4th Floor: 401,...
Program must use Python 3 Your program must have a welcome message for the user. Your...
Program must use Python 3 Your program must have a welcome message for the user. Your program must have one class called CashRegister. Your program will have an instance method called addItem which takes one parameter for price. The method should also keep track of the number of items in your cart. Your program should have two getter methods. getTotal – returns totalPrice getCount – returns the itemCount of the cart Your program must create an instance of the CashRegister...
The programming language is Python Instructions: Create a function that will delete a node in a...
The programming language is Python Instructions: Create a function that will delete a node in a Linked List based on position number. On below example, if you want to delete position #2, it will remove the Banana (arrangement of nodes below is Apple, Banana, Cherry, Grapes, Orange). myLinkedList = LinkedList() myLinkedList.append("Banana") myLinkedList.append("Cherry") myLinkedList.append("Grapes") myLinkedList.append("Orange") myLinkedList.prepend("Apple") myLinkedList.deleteByPositionNum(2) node = myLinkedList.head while node: print(node.value, " ") node = node.next_node You may start with the function head: def deleteByPositionNum(self, positionNum):
1.) Simplify the following expression to a minimum number of literals. This problem must be solved...
1.) Simplify the following expression to a minimum number of literals. This problem must be solved through Algebraic Manipulation. All work must be shown on the submitted work. Things to remember. If you can't see anything to work with from the beginning, expand. Formula Sheet has been provided. a.) Simplify (you MUST submit your work to get credit for this problem) F(a, b, c) = bc + a’b + ab’ + ac’ 2.) Express the given function in terms of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT