LaraBaltazarPA2

.docx

School

Washington State University *

*We aren’t endorsed by this school

Course

325

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

2

Uploaded by JusticeCrab4670

Lara Baltazar Programming Assignment 2 Chapter 2, Programming Exercise 14: Compound Interest Due September 10, 2023 at 6:00pm Description of the assignment: Create a program that would allow users to calculate the future value from a loan accruing compounded interest. This would be solved using user input for the principle, interest rate, compounded interest terms per year, and years compounded. The interest rate should be entered as a percentage. Program design: Chapter 2, Programming Exercise 14. Compound Interest Use the following values for the variables to test the program and illustrate input and output results: p = $1,000.00 r = 5% n = 12 t = 10 years Pseudocode: Get the starting principle, annual interest rate, compounding per year and years compounded from user input. Convert the interest rate as a percentage into decimal form. Calculate the future value and return the output. Python program code: #Get starting principle principle = float(input("Enter the starting principle: ")) #Get annual interest rate interest_rate = float(input("Enter the annual interest rate as a percentage: ")) #Get compounding per year compounding = float(input("How many times per year is the interest compounded?: ")) #Get years compounded time = float(input("For how many years will the account earn interest?: "))
#Calculate interest interest = interest_rate/100 #Calculate future value future_value = principle*((1+(interest/compounding))**(compounding*time)) print(f"At the end of {time:,.0f} years, you will have ${future_value:,.2f}.") Program input/output: Any errors encountered and how they were diagnosed/resolved: At first, the output was returned as $1,000. This was because of a calculation error in the formula. After solving said error, the program returned the correct amount. Applied learning with business context/takeaways: This assignment taught me how to: 1. Use the f-input command. 2. Adjust the number of digits being displayed to the right of a decimal point in the output of said f-input command. 3. Use different types of operations, including exponents as well as complex formulas within Python. Within a business context, this assignment simulates a situation in which I would need to code a program that can seamlessly calculate compound interest on a savings account or a loan.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help