Question
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(
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started