1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
SCORPION-xisa [38]
3 years ago
14

Write a program that calculates the future value of an investment at a given interest rate for a specified number of years. The

formula for the calculation is as follows:futureValue = investmentAmount * (1 + monthlyInterestRate)years*12
Computers and Technology
1 answer:
baherus [9]3 years ago
8 0
<h2>Question:</h2>

Write a program that calculates the future value of an investment at a given interest rate for a specified number of years. The formula for the calculation is as follows:

futureValue = investmentAmount * (1 + monthlyInterestRate) ^ years * 12

Note: Allow users to enter the values of the investmentAmount, monthlyInterestRate and years from standard input.

Assume the number of years is always a whole number.

<h2>Answer:</h2>

===================================================

//import the Scanner class

import java.util.Scanner;

//Class header definition

public class FutureValue{

   

    //Main method definition

    public static void main(String []args){

       

       //Create an object of the Scanner class

       Scanner input = new Scanner(System.in);

       

       //Prompt the user to enter the investment amount

       System.out.println("Enter the investment amount");

       

       //Store the input in a double variable called investmentAmount

       double investmentAmount = input.nextDouble();

       

       //Next, prompt the user to enter the interest rate

       System.out.println("Enter the interest rate in percentage");

       

       //Store the input in a double variable called interestRate

       double interestRate = input.nextDouble();

       

       //Convert the interest rate to decimal by multiplying by 0.01

       interestRate *= 0.01;

       

       //Convert the interest rate to monthly interest rate by dividing the

       //result above by 12

       double monthlyInterestRate = interestRate / 12;

       

       //Prompt the user to enter the number of years

       System.out.println("Enter the number of years");

       

       //Store the input in an integer variable called years

       int years = input.nextInt();

       

       //Using the given formula, find the future value

      double futureValue =  investmentAmount * Math.pow(1 + monthlyInterestRate, years * 12);

       

       //Print out the future value

      System.out.println("Future value : " + futureValue);

       

    } //End of main method

     

}  // End of class definition

===================================================

<h2>Sample Output</h2>

===================================================

<em>>> Enter the investment amount </em>

1000

>> <em>Enter the interest rate in percentage </em>

10

>> <em>Enter the number of years </em>

5

Future value : 1645.3089347785854

===================================================

<h2>Explanation:</h2>

The code above has been written using Java. The code contains comments explaining every line of the code. Please go through the comments. The actual lines of code have been written in bold-face to distinguish them from comments. A sample output has also been provided as a result of a run of the code.

You might be interested in
How often do you give or receive interpersonal support through social media? Consider times when you’ve exchanged supportive mes
Naily [24]

I receive interpersonal support on almost every sight I go on: even on this one right now! An example of interpersonal support can be a typing editor, I believe.

8 0
3 years ago
What is 4991 rounded to the nearest thousand
evablogger [386]

Answer:

5000

Explanation:

5 0
3 years ago
Read 2 more answers
Rita used information from a blog that someone else wrote. What should she do?
Shkiper50 [21]

Answer:

rita should either ask the original author for permission to use her blog, but the best answer woyuld be that she should site her sources.

Explanation:

7 0
2 years ago
What device do e-learning applications usually use to help users with visual
Tomtit [17]
The answer is Screen Readers.
6 0
2 years ago
Hannah receives an email from Keith, a subordinate who is about to start analyzing a market research report. Keith has never don
Oduvanchick [21]

Answer:

by writing her answers to the questions as a numbered or bulleted list

7 0
3 years ago
Other questions:
  • What is a bus master?
    14·1 answer
  • Does anyone take bca on plato
    11·1 answer
  • Indicate the proper order (1-4) of the following PR strategic planning 4-step process. 1 Defining the problem 2 Evaluating the p
    10·1 answer
  • Within a google form when looking which option do u use?
    13·1 answer
  • David owns a retail business that just implemented a web app to supplement sales. He needs to choose an attribution partner to i
    15·1 answer
  • WILL GIVEE BRAINLIEST ANSWER!!!!
    14·1 answer
  • How do you describe Microsoft excel?
    13·1 answer
  • Of what is famous Ted Nelson?​
    8·1 answer
  • What is the Digital Living Network Alliance ?
    5·2 answers
  • Briefly describe the working of computer processing system?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!