Explore BrainMass
Share

Explore BrainMass

    Implement a simple mortgage calculator in Python.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Implement a simple mortgage calculator in Python that calculates monthly mortgage payment amount such that each monthly payment repays same amount of principle, and monthly interest.

    When run, the program should display five menu options to perform mortgage related calculations and sixth option to exit the program, as indicated below.

    1. Monthly payment
    2. Total interest
    3. Monthly interest payment
    4. Principle left after monthly payment
    5. Daily payment rate for 30 days
    6. Exit the program

    All of the menu items perform different calculations and display result successfully.
    Program should continue asking user for a choice and performing relevant calculations, till user chooses to exit the program.

    © BrainMass Inc. brainmass.com October 10, 2019, 8:24 am ad1c9bdddf
    https://brainmass.com/computer-science/python/implement-simple-mortgage-calculator-python-624099

    Solution Preview

    You can execute the attached program as "python 624099.py", or you can follow given steps to execute it like "./624099.py".
    - chmod +x 624099.py
    - Ensure that first "#!" line specifies correct path to Python interpreter on your system.
    ----------------------------------------------------
    #! /usr/bin/python

    #
    # This program implements a simple Mortgage Calculator for the user.
    # It is considered that each monthly payment repays same amount of
    # principle, and interest, irrespective of whether it is first month
    # payment or last month payment.
    #

    # This function presents user with 6 choices, and returns a valid
    # choice made by user.

    def menu ():
    menuString = """
    Simple Mortgage Calculator
    --------------------------
    1. Monthly payment
    2. Total interest
    3. Monthly interest payment
    4. Principle left after monthly payment
    5. Daily payment rate for 30 days
    6. Exit the program
    """

    print(menuString)
    choice = int(input("Please choose an option: "))

    # Accept only a valid choice
    while (choice < ...

    Solution Summary

    Program validates user choice and does not proceed further till user makes a valid choice. Program is thoroughly modular, uses self documenting variable and function names, and is well commented for easier understanding. It makes use of if-elif-else and while-else statements.
    Python 2.7.8 was used during development and testing of the program.

    $2.19