Using switch case and loop in one problem.
4 views (last 30 days)
Show older comments
This is an interest problem. I have to create a program where the user needs to input an initial deposit amount, the interest rate, and select what the frequency of the compounding is (monthly, quarterly, semiannually, or annually) using a menu. I then need to use a for loop to determine what the amount of money that was accumulated in one year.
so far I have:
I=input('Enter initial deposit amount.');
R=input('Enter interest rate');
freq=menu('Select desired frequency of compounding','Monthly','Quarterly','Semianually','Annually');
I am not sure how to use a switch case and a for loop along with these user inputs. Any suggestions or at least guidance?
0 Comments
Answers (1)
Star Strider
on 22 Apr 2014
I suggest that you write the for loop first to be sure it works and calculates the compound interest correctly.
Then put them together to create you finished assignment.
5 Comments
Star Strider
on 22 Apr 2014
Not necessarily. Once you have the interest rate R and the compounding period freq, you can run the loop once at the end of switch...case...end block. Then print the result.
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!