Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Comment should this MNE have a global LGBT policy? Why/ why not?

Answered: 1 week ago