Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is python. i don't know how to make a code about this. please let me know. Activity #2: Calculating and writing to a file

This is python. i don't know how to make a code about this. please let me know.

image text in transcribedimage text in transcribedimage text in transcribed
Activity #2: Calculating and writing to a file - to be done individually Note: In Lab Assignment #8a, we practiced using Python to write data with multiple values to a file with each value separated by a comma. We then practiced using Python to read the data in that file into memory to do something useful with the data. This activity provides even more practice with what is called a CSV (Comma Separated Value) file. CSV files are one of the most common formats for storing tabular data (e.g. spreadsheets). Each line represents a row of the table, and the cells in each column are separated by commas. CSV files can usually be read by spreadsheet programs (such as Microsoft Excel), and most spreadsheet programs can output their data in the CSV format. These files are often given the .csv extension. In this activity, you will practice reading and writing data in the CSV format using Python. Write a program named Lab9b Act2. py that will write to a file a list of amortized values for a loan. Specifically, the program should: 1. Prompt the user for an output file name for the data2. Prompt the user for the initial amount of the loan (P), the number of months (N) over which the loan will be repaid, and the annual interest rate (i). (Note that i should be a decimal number, not a percentage: 0.025 not 2.5%) 3. Calculate the monthly payment (M) as shown below. Note: J = i/12 M = P . J 1- (1+1 ) a. Note: You should verify your program's calculations: e.g. for P = $100000, N = 60, i = 0.025 the monthly payment should be M - $1774.74 4. Open the output file for writing 5. Write to the output file column headers for the table as comma-separated strings: Month, Total Accrued Interest, Loan Balance 6. Write to the output file the initial values for the month number, the total amount of interest accrued so far, and the amount remaining on the loan, separated by commas: 0, $0.00, $P . pp where P . pp is the initial value of the amount of the loan) 7. For each month, starting with month 1 and ending when the amount remaining on the loan is less than $0.01: a. Calculate the accrued interest by multiplying the balance at the beginning of the month by J = i/12 b. Calculate the balance at the end of the month by adding the accrued interest to the beginning balance and subtracting the monthly payment C. Write to the output file the month number, the total amount of interest accrued so far (to the nearest penny), and the amount remaining on the loan (to the nearest penny), separated by commas (see output format below) Note: If you write your CSV file correctly, you should be able to open it in a spreadsheet program that can read CSV files (like Excel). You can also check the values themselves using the PMT ( ) function in Excel, e.g. PMT (0. 025/12, 60, 100000) = ($1774.74). Example Input (bold red is user input): Enter output file: out. csv Enter principal amount: 100000 Enter term length (months) : 60 Enter annual interest rate: 0.025 Output out . csv (created by the program): Month, Total Accrued Interest, Loan Balance 0, $0. 00, $100000.00 1, $208. 33, $98433.60 59, $6480. 48, $1771.05 60, $6484. 17, $0.00\f

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

5. What are invisibles in the balance of payments?

Answered: 1 week ago