Java Reference
In-Depth Information
*4.30
( Financial application: compound value ) Suppose you save $100 each month into
a savings account with the annual interest rate 5%. So, the monthly interest rate is
0.05 / 12 = 0.00417 . After the first month, the value in the account becomes
100 * (1 + 0.00417) = 100.417
After the second month, the value in the account becomes
(100 + 100.417) * (1 + 0.00417) = 201.252
After the third month, the value in the account becomes
(100 + 201.252) * (1 + 0.00417) = 302.507
and so on.
Write a program that prompts the user to enter an amount (e.g., 100 ), the annual
interest rate (e.g., 5 ), and the number of months (e.g., 6 ) and displays the amount
in the savings account after the given month.
*4.31
( Financial application: compute CD value ) Suppose you put $10,000 into a CD
with an annual percentage yield of 5.75%. After one month, the CD is worth
10000 + 10000 * 5.75 / 1200 = 10047.91
After two months, the CD is worth
10047.91 + 10047.91 * 5.75 / 1200 = 10096.06
After three months, the CD is worth
10096.06 + 10096.06 * 5.75 / 1200 = 10144.43
and so on.
Write a program that prompts the user to enter an amount (e.g., 10000 ), the annual
percentage yield (e.g., 5.75 ), and the number of months (e.g., 18 ) and displays a
table as shown in the sample run.
Enter the initial deposit amount:
Enter annual percentage yield:
Enter maturity period (number of months):
10000
5.75
18
Month CD Value
1
10047.91
2
10096.06
...
17
10846.56
18
10898.54
**4.32
( Game: lottery ) Revise Listing 3.9, Lottery.java, to generate a lottery of a two-
digit number. The two digits in the number are distinct. ( Hint : Generate the first
digit. Use a loop to continuously generate the second digit until it is different from
the first digit.)
 
Search WWH ::




Custom Search