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 namedyears and one Scanner variable named input. Declare the variables in the order listed. Declare presentValue, interestRate, andfutureValue 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. --------------------------------------------------- /** * Purpose: This program calculates the future * value of an investment. */ import java.util.Scanner; public class CalculateFutureValue { public static void main(String[] args) { //Write the required statements. } // end method main } // end class CalculateFutureValue

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

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions