早教吧作业答案频道 -->其他-->
帮忙用textpad写一串JAVA编码,程序要求在下方。答的好的加50分1.Writeaprogramthatreadsininvestmentamount,annualinterestrate,andnumberofyears,anddisplaysthefutureinvestmentvalueusingthefollowingformula:futur
题目详情
帮忙用textpad写一串JAVA编码,程序要求在下方。答的好的加50分
1. Write a program that reads in investment amount, annual interest rate, and number
of years, and displays the future investment value using the following formula:
futureInvestmentValue = investmentAmount(1+monthlyInterestRate)numberOfYears*12
Hint: Use the Math.pow(a, b) method to compute a raised to the power of b.
1. Write a program that reads in investment amount, annual interest rate, and number
of years, and displays the future investment value using the following formula:
futureInvestmentValue = investmentAmount(1+monthlyInterestRate)numberOfYears*12
Hint: Use the Math.pow(a, b) method to compute a raised to the power of b.
▼优质解答
答案和解析
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));
}
}
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));
}
}
看了 帮忙用textpad写一串J...的网友还看了以下:
如何用Matlab求出下面这种一元方程的解.如何用Matlab求出下面一元方程的解.或者说,如何求 2020-05-17 …
在虚拟8086模式下,应用程序的特权级是A.0级B.1级C.2级D.3级 2020-05-23 …
Pentium 4微处理器的特权等级分为0-3四个等级。在虚拟8086模式下,应用程序是在【】级上运 2020-05-23 …
在虚拟8086模式下,应用程序的特权级是下面的______。A.0级B.1级C.2级D.3级 2020-05-24 …
在虚拟8086模式下,应用程序的特权级是______。A.0级B.1级C.2级D.3级 2020-05-24 …
在虚拟8086模式下,应用程序的特权级是( )。A.0级B.1级C.2级D.3级 2020-05-24 …
Pentium微处理器在虚拟8086模式下,应用程序的可寻址内存空间是______MB。 2020-05-24 …
阅读以下应用程序说明和C程序,将C程序段中(1)~(7)空缺处的语句填写完整。[说明] 以下[C程序 2020-05-26 …
数学的应用题某工程限期完成,甲队做正好按期完成,乙队单独做要延误3天,现两队合作2天后余下的工程由乙 2020-11-05 …
数学应用题.帮忙看下.谢谢.某工程限期完成,甲工程队单独提前1天完成,乙工程队单独做延期2天完成,现 2020-11-05 …