Question: 1. Create a new class named Math.java. For this program you will be required to use the Math class (found in the java.lang package) and

1. Create a new class named Math.java. For this program you will be required to use the Math class (found in the java.lang package) and the DecimalFormat class and the NumberFormat.getCurrencyInstance() method (these are found in the java.text package and will need to be imported). Inside the main() method, do the following:

a. This program will calculate the present value of a future amount, using the compound interest formula:

presentValue = futureValue/(1 + annualInterestRate)yearsInFuture

b. Declare primitives (and initialize them) for the following (choose appropriate data types) :

i. presentValue = 0

ii. futureValue = 1000000

iii. annualInterestRate = this should be a random number between 0% and 10% (use the Math.random() method)

iv. yearsInFuture = 20

c. Your program should calculate the present value of the one million dollars.

d. As well, instantiate two (2) different (appropriately named) DecimalFormat objects, one that will display the dollar amounts appropriately, and one that will

display interest rates to 3 decimal places (a leading zero if the interest rate is less than 1%).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!