![]() |
![]() Second Summer 2002 |
In this assignment you will be
practicing with while
and for
loops.
First, write an algorithm to settle the following question:
A bank account starts out withThis problem is listed as Exercise R1.16 (page 44) in your text.$10,000
. Interest is compounded at the end of every month at6
percent per year (0.5
percent per month). At the beginning of every month,$500
is withdrawn to meet college expenses after the interest has been credited. After how many years is the account depleted?
Now suppose the numbers (This extension is listed as Exercise R1.17 (page 44). This will be your assignment.$10,000
,6
percent,$500
) were user-selectable. Are there values for which the algorithm you developed would not terminate? If so, make sure it always terminates.
Therefore you are to write a program that asks the user for three values:
double
)
double
, a percent value)
double
, in dollars)
frilled.cs.indiana.edu%java Interests Welcome to the financial calculator. What's your initial balance? 10000 What's the yearly interest? 6 How much do you plan to withdraw monthly? 500 The account will last 1 year(s) and 9 month(s). Ending balance will be: 62.2 dollars. frilled.cs.indiana.edu%java Interests Welcome to the financial calculator. What's your initial balance? 10000 What's the yearly interest? 6 How much do you plan to withdraw monthly? 100 The account will last 11 year(s) and 6 month(s). Ending balance will be: 97.09 dollars. frilled.cs.indiana.edu%java Interests Welcome to the financial calculator. What's your initial balance? 10000 What's the yearly interest? 6 How much do you plan to withdraw monthly? 10 This will last forever. frilled.cs.indiana.edu%java Interests Welcome to the financial calculator. What's your initial balance? 10000 What's the yearly interest? 6 How much do you plan to withdraw monthly? 50 The account will last 525 year(s) and 1 month(s). Ending balance will be: 48.1 dollars. frilled.cs.indiana.edu%
Please
call your program (the class)
Interests
for faster grading.
Do you see anything fishy in the examples given? (I hope you do.) What is it?
What do you plan to do about it in your program?frilled.cs.indiana.edu%webster fishy fishy \'fish-e^-\ fish-i-er; -est (1547) 1: of or resembling fish esp. in taste or odor 2: creating doubt or suspicion: QUESTIONABLE frilled.cs.indiana.edu%