compound interest using for loop
이전 댓글 표시
£1000 was deposited in a bank account that pays 4% interest annually. The balance will grow as follows: balance = current balance + 0.04*(current balance)
a) use for loop to calculate account balance from year 1 to year 20
b) plot of annual balance from year 1 to year 10, adding axis to the graph
c)print to the screen the balance (2 d.p) at year 10
your message should displace " your account balance after 10 Years is £1480.24"
댓글 수: 5
Guillaume
2017년 3월 31일
So, what efforts have you made towards writing the 6 lines or so required to solve this extremely easy homework?
Harry Chichi
2017년 3월 31일
Guillaume
2017년 3월 31일
Then show us the code that you wrote.
Steven Lord
2017년 3월 31일
Show us what you've written and we may be able to point out the problem that's causing your loop to run infinitely.
Adam
2017년 3월 31일
If you are going to edit away your questions after they get answered then don't expect people to be in a hurry to answer your future questions.
People are more than willing to help when you show some effort, but this forum is for people to be able to search and find existing answers to questions they have also. That isn't possible if people just edit away their question as soon as they have been given an answer and it annoys those who gave their time to provide that answer.
답변 (1개)
2) While you could indeed use a while loop, that loops must end after 20 years. Your loop runs while the balance is greater than 20. This is of course forever since the balance start greater than 20 and keeps growing.
댓글 수: 4
Harry Chichi
2017년 3월 31일
Guillaume
2017년 3월 31일
Well, which variable do you use to count the years? Make sure that it stays under 20 in the while loop by translating while numberofyears is less than or equal to 20 into matlab code. It's not that hard.
Steven Lord
2017년 3월 31일
Use the plot function.
Elisabeth Quan
2021년 9월 27일
why are the "experts" on this site so rude and dismissive?! i.e.: Guillaume saying "it's not that hard." Maybe it's not that hard FOR YOU because this is a subject that you understand, but this language is very counterintuitive and frustrating.
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!