-
If you haven't already done so, complete the homework assigned
previously.
-
Write a Python app that determines the compounded amount of an investment over
a ten year period, where the initial investment accrues interest annually and that
interest is added to the total investment amount. Then
consider a range of annual interest rates, entered as integers and starting at a value provided by the
end-user, ending with a value provided by the end-user, and incrementing at a
step value provided by the end-user. In addition, the end-user is to be prompted
for an initial investment amount. The app is to display a one-dimensional table
showing the compounded investment amount for each of the interest rates as
as specified by the end-user. The coding for this app involves a repetition
construct, as well as possibly one or more selection constructs. The app is to
have two versions, both identical in their interfaces, calculations, and
interactons with the end-user. The versions differ only in the type of
repetition construct used: a while() loop, and a
for() loop using the range() function
(which together are essentially considered a foreach()
construct in other languages), corresponding
respectively with Versions A and B. FYI, the formula for compounded
future value of an investment of amount P is
P×(1 + i)n, where i is
the interest rate and n is the number of years in the compounding
term. Use a formatted
print(), i.e., a print(f'...'), function
to display the results.
Recommended names for the code files are invAnalysisApp2023a
and invAnalysisApp2023b, and recommended names for the
variables and named constants are as follows.
- fltPrincipal → amount invested
- intMinRate → minimum interest rate to consider
- intMaxRate → maximum interest rate to consider
- intRateStep → interest rate increment
- intArrRates → array of interest rates specified by the range provided
- intIntRate → current interest rate being considered
- fltCompInvestment → future value of compounded investment
- INVESTMENT_TERM → constant specifying investment term in years
- TITLE_0 → constant containing first line of app title
- TITLE_1 → constant containing second line of app title
- SECTION_1 → section header (inputs)
- SECTION_2 → section header (outputs)
-
Enhance the Investment Analysis app described above so that the outputs are displayed
in a two dimensional table, and the inputs include minimum, maximum, and step values
for the investment term. However, use only the for() coding for the
repetition construct.
The recommended name for the code file is invAnalysisApp2023c,
and, in addition to the above names, recommended names for the
variables and named constants are as follows.
- intMinTerm → minimum term to consider
- intMaxTerm → maximum term to consider
- intTermStep → term increment
- intArrTerms → array of terms specified by the range provided
- intTerm → current term being considered