Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4 . In the main method, right below the code you wrote for step 3 , write the code to find the investment value for

4. In the main method, right below the code you wrote for step 3, write the code to find the
investment value for each year and the total interested earned on an initial investment of
$125000.00. Your rate of returns for years 14 are as follows:
Year 1 return is 5%
Year 2return is 9%
Year 3 return is -3.5%
Year 4 return is 7%
Create the following variables and complete the code based on the information given.
Hint: totalInterestEarned is the total amount of money youve gained after the 4 years of
investing, so it should be calculated last.
double initialInvestment ...
double year1InterestRate ...
double year2InterestRate ...
double year3InterestRate ...
double year4InterestRate ...
double totalInterestEarned ...
Use a simple interest formula to calculate the investment values for each year.
double year1InvestmentValue ...;
double year2InvestmentValue ...
double year3InvestmentValue...
double year4InvestmentValue ...
Calculate your investment value after each year and output the following:
NOTE: First use println() to output the values once, then use printf() to output them again with
the right formatters. All your output must align to get full credit.
Remember to call printStepHeader(...) with the right input to output the header.
Output for this Step(Yours should match exactly): ===================================
Step: 4
===================================
USING PRINTLN
initialInvestment: 125000.0
year1InvestmentValue: 131250.0
year2InvestmentValue: 143062.5
year3InvestmentValue: 138055.3125
year4InvestmentValue: 147719.184375
totalInterestEarned: 22719.18437500001
USING PRINTF with format -> right justified, 10 min places,2 decimal places
initialInvestment: 125000.00
year1InvestmentValue: 131250.00
year2InvestmentValue: 143062.50
year3InvestmentValue: 138055.31
year4InvestmentValue: 147719.18

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

Step: 3

blur-text-image

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

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions