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
Plese give three examples of specilized servers.
MariettaO [177]
1.Extended border node (EBN)
2.Central directory server (CDS)
3.Branch extender (BEX or BrEx or BrNN)
5 0
3 years ago
Read 2 more answers
How to do 2. Pleaser
V125BC [204]

Answer:

GOD HAS FORSAKEN YOU NOW PRAISE DHAR MANN

6 0
3 years ago
PERGUNTA 1
Genrish500 [490]

Answer:hola no conozco el toldo, pero necesito puntos cerebrales tan lo siento

Explanation:

8 0
2 years ago
A tooltip is a _____________ that allows the programmer to create a small popup message that displays when the user places the m
Shalnov [3]
I believe a message
7 0
3 years ago
Read 2 more answers
According to a case study in one of our weekly chapter reading, nearly..................... percent of all employees send work e
ozzi

Answer:

A.80, and uncontrolled

3 0
3 years ago
Read 2 more answers
Other questions:
  • The purpose of the ________ element is used to configure the main content of a web page document.
    5·1 answer
  • Why were mechanical calculators developed?
    8·2 answers
  • How is a computer component, such as a network card, commonly marked for identification?
    12·1 answer
  • What would happen if computers only had input devices?
    9·1 answer
  • Name the application used for creating Presentations___
    5·2 answers
  • With a heat exchanger, the temperature of the process fluid can be measured with a temperature-
    14·1 answer
  • Choose all stages of the information processing cycle.
    12·2 answers
  • How you use ict today and how will you use it tomorrow
    14·1 answer
  • Set of general format used to write program in any programming language?​
    10·1 answer
  • How is a WAN different from a LAN?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!