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
The first step in the information processing cycle is _____, which involves entering data into the computer.
Dmitry [639]

Answer:

INPUT

Explanation:

Information Processing Cycle is defined as the series of stages followed in processing information. Those stages include:

  • Input
  • Processing
  • Storage
  • Output

Input involve entering the data/information into the computer

Processing involve the computer performing some computation on the data

Storage involve saving the data and/or result to the any medium for future use.

Output involve displaying or presenting the results to the user.

4 0
3 years ago
____ is one of the primary operations of a computer.
Romashka [77]
Processing <span>is one of the primary operations of a computer.</span>
7 0
2 years ago
Justine was interested in learning how to play the piano. Before she was allowed to even play the piano, she has had to learn
Setler [38]

Answer:

A

Explanation:

The answer is A because, to be novice at something that means one is new to and is inexperienced at said activity.

3 0
2 years ago
Read 2 more answers
Moore’s law refers to?
puteri [66]

Answer:

Moore’s law states that processor speeds, or overall processing power for computers will double every two years.

Explanation:

  • Moore’s law is more than an observation than a law which was originated in 1970. The observation is about the number of transistors that is present in any system or an integrated system that will be doubled every couple of years.
  • The real-world application of Moore's law can be seen during computing your business taxes, piloting a spaceship, or changing the television station, etc.
7 0
2 years ago
When driving, your attention is __________.
maks197457 [2]
It is c hope I helped
7 0
2 years ago
Read 2 more answers
Other questions:
  • Jose calls you at the help desk because he is having a problem logging on to his laptop computer. After several unsuccessful att
    14·1 answer
  • The groups_per_user function receives a dictionary, which contains group names with the list of users. Users can belong to multi
    11·1 answer
  • How do you know if you get a phone call that is a scam
    8·2 answers
  • Who is president is US
    5·1 answer
  • Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follo
    5·1 answer
  • Which function will add a name to a list of baseball players in Python?
    13·2 answers
  • . Some countries lack physical resources, like computers or network connections, making it difficult to keep up with the technol
    8·2 answers
  • What is a fire wall and how does it work
    6·1 answer
  • 6.16 LAB: Find largest number (EO) Write a method, findMax(), that repeatedly reads in integers until a negative integer is read
    9·1 answer
  • . prevalence of coronary artery disease in patients with isolated aortic valve stenosis. br heart j. 1984;51:121–4.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!