java - 找不到符号错误,类型不兼容

标签 java

您好,我正在尝试编写一个程序,使用固定利率计算 future 的投资值(value),但我的变量存在问题。任何帮助将不胜感激,提前谢谢!

  /**
  * NAME:
  * DATE: November 3, 2015
  * FILE: 
  * COMMENTS: This program caculates a future investment value using a fixed rate
  */
  import java.util.Scanner;

public class lab12
{
   public static void main(String[] args)
   {
   //declare variables
   double yearlyInterstRate;
   double monthlyInterestRate;
   double monthlyInvestmentAmount;
   double years;
   double months;

   //Create Scanner Object
   Scanner keyboard= new Scanner(System.in);

   //Get Investment Information
   System.out.print("Hello we will be caculating the future of your fixed monthly investment, I will need to collect some information from you.");
   System.out.print("What is your monthly investment amount?");
   monthlyInvestmentRate=keyboard.nextLine();
   System.out.print("How many years wil you be investing for?");
   years=keyboard.nextLine();
   System.out.print("What is your yearly interest rate?");
   yearlyInterestRate=keyboard.nextLine();
   //Caculate the future rate
   {
      months=years*12;
      monthlyInterestRate=yearlyInterestRate/12/100;
      futureValue= CaculateFuturevalue(monthlyInvestedAmount,monthlyInterestRate,months);
      System.out.print("Your future value is $"+futureValue);
    }
 } //Close Main
} //close lab12

最佳答案

您的变量拼写错误。

您已声明 yearlyInterstRate,但正在使用 yearlyInterestRate,因此您需要使用声明的变量。

您还需要使用monthlyInvestmentAmount而不是monthlyInterestRate

关于java - 找不到符号错误,类型不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33910629/

相关文章:

java - Switch 语句给出不兼容的类型错误

java - 使用 JFileChooser 将文件插入到 Jlabel 中

java - 如何将按钮链接到操作监听器和文本字段?

java - 在 QueryContext Oracle 的数字 varchar 字段中附加前导零

java - (isUserInRole()) 是将用户权限/安全性附加到 JSF 按钮的最简单方法吗?

java - 如何为我获得的两个输出留出一些空间?

java - 声明两个字段 volatile 就足够了吗?

java - 如何显示抽屉导航中的 fragment ?

java - 我想知道 'detached entity passed to persist' 发生的原因

java - 无法在 string.hasNextLine 循环中使用 string.nextInt