gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 04:09:42 24 4
gpt4 key购买 nike

您好,我正在尝试编写一个程序,使用固定利率计算 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com