Quiz1_Practice_InterestCalc

.pdf

School

New York University *

*We aren’t endorsed by this school

Course

UB23

Subject

Computer Science

Date

Jan 9, 2024

Type

pdf

Pages

2

Uploaded by MasterPuppy901

Report
Name: __________________________ Intro to Programming & Data Science (TECH.UB.23) QUIZ 1, PART 2 (50/100 points) PRACTICE QUESTION This section of the midterm consists of a program you need to write using the IDLE text editor and shell. You can use your textbook, slides, notes and any online resources for this section. Please hand this sheet back (with your name filled out) to the TA after you have completed the exam. Submit your final script (as a .py file named LName_Fname_Quiz1.py) through the Brightspace portal under “ Quiz1 in Assignments. Partial credit will be given. Please be sure to make sure your submission went through ok on the Assignments portal. You must submit your program by the end of class. Any late entries may not be counted. Context: You are working with a non-profit that is trying to educate young people to save. You want to show them the power of compounding interest (how your money starts earning money after a while). To show them how much more their money can be worth by investing in a CD or Treasury, you are asked to write a program as specified below. Compounding Interest: In order to calculate compound interest, you need to multiply the value of the year before with the interest rate. For example, the value in year 1 is: principal * (1 + rate). The value in year 2 is the value in year 1 * (1 + rate). Requirements: Create a program that meets the following criteria: - Asks the user to enter a principal or starting amount (call this variable principal ), enter the interest rate they expect to earn (call this variable “rate”), and ask the user how many years they would like to invest for (call this variable “years”). - Create a function called opening that prints the title of the program, “The Compound Interest Calculator”) - Create a function called “calculate” that calculates the value in each year (call this “final” ) using the principal, rate and years variables. This function should also prints the value that the user will have at the given interest rate for each year and return the final value as an output of the function as the variable “final”. - Create a functi on called “closing” that prints a closing statement using the final value, e.g. “The final value of your investment is nnn.” - Nest all your request for input and operations within a main function. If the program is run, the main function should run. TURN THE PAGE FOR A VISUALIZATION OF THE CONSOLE & SOME TIPS
_____________________________________________ The Compound Interest Calculator Enter principal: 5000 Enter the interest rate: 4.67 Enter number of years: 5 Year 1: 5233.5 Year 2: 5477.9 Year 3: 5733.72 Year 4: 6001.48 Year 5: 6281.75 Thanks for using this program! The final value of your investment is: 6281.75 ___________________________________________ Be sure to make sure your text, spacing, breaks and number formats look exactly like the sample above. Partial credit will be given even if you aren’t able to get the program to run, don’t incl ude the main function or c an’t get the program to loop. GOOD LUCK!
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