Question

Write a program that calculates the amount of mone
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;
public class Value{

    static int getYears(){
        Scanner sc = new Scanner(System.in);
        System.out.print("Number of Years: ");
        int years = sc.nextInt();
        sc.close();
        if (years>=0)
            return years;
        else
            return 0;
    }

    static double getAnnualIntRate(){
        Scanner sc = new Scanner(System.in);
        System.out.print("Annual Interest Rate: ");
        double rate = sc.nextDouble();
        sc.close();
        if (rate>=0)
            return rate;
        else
            return 0;
    }

    static double getFutureValue(){
        Scanner sc = new Scanner(System.in);
        System.out.print("Future Value: ");
        double futureValue = sc.nextDouble();
        sc.close();
        if (futureValue>=0)
            return futureValue;
        else
            return 0;
    }

    static double calcPresentValue(double futureValue, double rate, int years){
        return futureValue/Math.pow(1.0+rate/100.0, years);
    }

    public static void main(String[] args) {
        double futureValue = getFutureValue();
        double rate = getAnnualIntRate();
        int years = getYears();
        System.out.println("You need to deposit " + calcPresentValue(futureValue, rate, years));
    }
}

Add a comment
Know the answer?
Add Answer to:
Write a program that calculates the amount of money that you must invest In a savings...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (C++) Suppose you have a certain amount of money is a savings account that earns compound...

    (C++) Suppose you have a certain amount of money is a savings account that earns compound monthly interest, and you want to calculate the amount that you will have after a specific number of months. The formula, which is known as the future value formula, is: F = P x (1 + i)t The terms in the formula are as follows: a. F is the future value of the account after the specified time period b. P is the present...

  • Suppose you want to deposit a certain amount of money into a savings account and then...

    Suppose you want to deposit a certain amount of money into a savings account and then leave it alone to draw interest for the next 10 years. At the end of 10 years you would like to have $10,000 in the account. How much do you need to deposit today make that happen? You can use the following formula, which is known as the present value formula, to find out:                                    P = F / (1+ r)^n The terms in...

  • P5.3      Present Value. Suppose you want to deposit a certain amount of money into a savings...

    P5.3      Present Value. Suppose you want to deposit a certain amount of money into a savings account and then leave it alone to draw interest for the next 10 years. At the end of 10 years you would like to have $10,000 in the account. How much do you need to deposit today tomake that happen? You can use the following formula, which is known as the present value formula, to find out: P = F/(1+r)^n The terms in the...

  • I need help with this code: Write a program that calculates the future value of an...

    I need help with this code: 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 Use text fields for interest rate, investment amount, and years. Display the future amount in a text field when the user clicks the Calculate button, as shown in the following figure. It needs to be done in...

  • Please help me do this program. Add some comments on it. *15.5 (Create an investment-value calculator)...

    Please help me do this program. Add some comments on it. *15.5 (Create an investment-value calculator) Write a program that calculates the future value of an investment at a for the calculation is given interest rate for a specified number of years. The formula investmentAmount * (1monthlyInterestRate ) years *12 futureValue Use text fields for the investment amount, number of years, and annual interest rate. Display the future amount in a text field when the user clicks the Calculate button,...

  • Suppose you have a certain amount of money in a savings account that earns compound monthly...

    Suppose you have a certain amount of money in a savings account that earns compound monthly interest, and you want to calculate the amount that you will have after a specific number of months. The formula is as follows: f = p * (1 + i)^t • f is the future value of the account after the specified time period. • p is the present value of the account. • i is the monthly interest rate. • t is the...

  • LULUPULUS! WORK AREA Suppose you have a certain amount of money in a savings account that...

    LULUPULUS! WORK AREA Suppose you have a certain amount of money in a savings account that earns compound monthly interest, and you want to calculate the amount that you will have after a specific number of months. The formula is as follows: f=p* (1 + i)^t • fis the future value of the account after the specified time period. •p is the present value of the account. i is the monthly interest rate. .t is the number of months How...

  • C++ 18. Savings Account Balance Write a program that calculates the balance of a savings account...

    C++ 18. Savings Account Balance Write a program that calculates the balance of a savings account at the end of a three month period. It should ask the user for the starting balance and the annual interest rate. A loop should then iterate once for every month in the period, performing the following A) Ask the user for the total amount deposited into the account during that month. Do not accept negative numbers. This amount should be added to the...

  • Write a program using Python that calculates the amount of money a person would earn over...

    Write a program using Python that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should ask the user for the number of days. Display a table showing what the salary was for each day, then show the total pay at the end of the period. The output should be displayed...

  • Using Javascript! Write a program that calculates the amount of money a person would earn over...

    Using Javascript! Write a program that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should ask the user for the number of days. Display a table showing what the salary was for each day, and then show the total pay at the end of the period. The output should be...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT