Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program called CalculateFutureValue that calculates the future value of an investment based on compounding interest. Your program must declare three double variables named

Write a program called CalculateFutureValue that calculates the future value of an investment based on compounding interest. Your program must declare three double variables named presentValue, interestRate, and futureValue. Also, declare an integer variable named years and one Scanner variable named input. Declare the variables in the order listed. Declare presentValue, interestRate, and futureValue on the same line and initialize each to 0.0. Declare and initialize years to 0. The program will prompt the user for the present value, interest rate, and years and read the input from the keyboard storing each value in its respective variable (presentValue, interestRate, and years). Use the formula below to calculate the future value and store the result in the variable futureValue. Use the correct format specifier to print the future value. Use two % signs to get a % to print.

futureValue = presentValue x (1 + interestRate)years

Important Note: To raise a number to a power, use the Math.pow() command. (Notice the M in Math is capitalized.) The format in Java is:

Math.pow(, ) Example: Math.pow(10, 2); <-- This returns the value 100.

The required output is provided. The "%s" is not used.

Example output below:

Enter the present value: 1000

Enter the interest rate (6.0% = 0.06): .12

Enter the number of years: 6

The future value after 6 years is $1,973.82.

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

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

Define Management or What is Management?

Answered: 1 week ago

Question

What do you understand by MBO?

Answered: 1 week ago

Question

What is meant by planning or define planning?

Answered: 1 week ago