我有一个问题,输出应该是双重的,但它是字符串 我想添加两个double值,但它将它作为一个字符串。我正在使用eclipse。目前该程序正在编译和运行。如果有人有片刻我会很感激。干杯。这是源代码。double + double = String?
import java.util.Scanner;
public class FutureInvestment
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter investment amount: ");
double investmentAmount = input.nextDouble();
System.out.println("Enter monthly interest rate: ");
double monthlyInterestRate = input.nextDouble();
System.out.println("Enter number of years: ");
int numberOfYears = input.nextInt();
double futureInterestValue = investmentAmount * (Math.pow((1 + monthlyInterestRate), numberOfYears * 12));
System.out.println("Accumulated value is: " + futureInterestValue + investmentAmount);
}
}
这里的输出我得到进入投资金额:输入月息: 4.25 输入的年数:累计值是:4.384414858452464E111000.0 – Kiril 2012-02-26 15:55:01
和预期结果的累计值1043.34 – Kiril 2012-02-26 15:55:19
我想我的回答可以帮助你 – 2012-02-26 16:07:25