Insights Blog
-- Browse All Articles --
Physics Articles
Physics Tutorials
Physics Guides
Physics FAQ
Math Articles
Math Tutorials
Math Guides
Math FAQ
Education Articles
Education Guides
Bio/Chem Articles
Technology Guides
Computer Science Tutorials
Forums
Intro Physics Homework Help
Advanced Physics Homework Help
Precalculus Homework Help
Calculus Homework Help
Bio/Chem Homework Help
Engineering Homework Help
Trending
Featured Threads
Log in
Register
What's new
Search
Search
Search titles only
By:
Intro Physics Homework Help
Advanced Physics Homework Help
Precalculus Homework Help
Calculus Homework Help
Bio/Chem Homework Help
Engineering Homework Help
Menu
Log in
Register
Navigation
More options
Contact us
Close Menu
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Forums
Homework Help
Engineering and Comp Sci Homework Help
Compound interest loops problem (matlab)
Reply to thread
Message
[QUOTE="gfd43tg, post: 4779310, member: 500468"] [h2]Homework Statement [/h2] (a) Suppose you decide to invest money in a Certificate of Deposit (CD). Write code that assigns to the variable FinalValue the final value of the CD based on the following variables: Investment: the initial amount of money invested in the CD, Rate: the annual interest rate of the CD, and Term: the term length of the CD in years. The interest of the CD should be compounded annually (i.e., at the end of each year the value of the CD increases by the interest rate times the current value of the CD). Example: If Investment equals 100, Rate = 0.0235 and Term equals 1, then FinalValue should be assigned a value of 102.35. (b) Write code that assigns to the variable numYears, an integer number of years required for the value of the CD to exceed twice the original value given by the variable Investment (as in Problem 1a) with the interest rate given by the variable Rate (as in Problem 1a). [h2]Homework Equations[/h2] [h2]The Attempt at a Solution[/h2] I got part (a) of the problem [CODE]Rate = 0.05; Term = 10; Investment = 1000; FinalValue = Investment; for k = 1:Term FinalValue = FinalValue + Rate*FinalValue; end[/CODE] But now I am stuck on part (b). I don't know how to incorporate numYears into my while loop. Also, when I run what I have right now in its present form, I get FinalValue = 1000 [CODE]Rate = 0.05; Investment = 1000; FinalValue = Investment; while FinalValue < 2*Investment; FinalValue = FinalValue + Rate*FinalValue; end[/CODE] Edit: I didn't realize that the while will skip the commands in the loop if false. I assumed it would check for truth, and if not true, redo the loop until true. Hence I changed the > to a <. That seems backwards to me... Now I know FinalValue is 2.0789e+03. I ran it without the commas and 15 executions gives me that value. Now I need to figure out how to assign numYears to the number of times the loop executed. Edit: nevermind, just found out about the Count [/QUOTE]
Insert quotes…
Post reply
Forums
Homework Help
Engineering and Comp Sci Homework Help
Compound interest loops problem (matlab)
Back
Top