好的,所以我似乎无法通过将 inputP * inputR 相乘来找到我的兴趣,假设这是因为我的扫描仪变量 inputR 和 inputP 即使在使用此方法后仍未转换为双变量: System.out.println(inputR.nextDouble( )); - 问题是什么?
import java.util.Scanner;
public class test {
//This program will display the value of the principle for each of the next 5 years
public static void main(String[] args) {
Scanner inputR = new Scanner(System.in); Scanner inputP = new Scanner(System.in);
double years = 0;
System.out.println("Please enter the principle value for year one: ");
System.out.println(inputP.nextDouble());
System.out.println("Please enter the interest rate for year one: ");
System.out.println(inputR.nextDouble());
while (years < 5) {
double interest;
years = years + 1;
interest = inputP * inputR;
principle = inputP + interest;
System.out.println("Your principle after 5 years is: " + principle);
}
}
}