帮忙用textpad写一串JAVA编码,程序要求在下方。答的好的加50分

1个回答

  • import java.io.BufferedReader;

    import java.io.IOException;

    import java.io.InputStreamReader;

    /*

    * 2.9 (Calculatingthe future investment value) Write a program that reads ininvestment amount,

    * annual interestrate, and number of years, and display the future investment valueusing the

    * followingformula:

    futureInvestmentValue =

    investmentAmount x(1 + monthlyInterestRate)numberofYears*12

    For example, if youentered amount 1000, annual interest rate 3.25%, and number ofyears 1, the future investment value is 1032.98.

    Hint:

    Use the Math.pow (a,b) method to compute a raised to the power of b.

    */

    public class InvestmenntValue{

    public static void main(String[] args)throwsIOException {

    double investmentAmount =0.0;

    double yearlyInterestRate =0.0;

    double monthlyInterest =0.0;

    int years = 0;

    double futureInvestmentValue =0.0;

    double temp = 0.0;

    BufferedReader my_Buffer;

    my_Buffer =newBufferedReader(new InputStreamReader(System.in));

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

    investmentAmount =Double.parseDouble(my_Buffer.readLine());

    System.out.println("Enter annualinterest rate : " );

    yearlyInterestRate =Double.parseDouble(my_Buffer.readLine());

    System.out.println("Enter years: ");

    years =Integer.parseInt(my_Buffer.readLine());

    yearlyInterestRate /=100.0;

    monthlyInterest = yearlyInterestRate/ 12.0;

    years *= 12;

    temp = investmentAmount * (1 +monthlyInterest);

    futureInvestmentValue =Math.pow(temp, years);

    System.out.println("Answer = "+String.valueOf(futureInvestmentValue));

    }

    }