gpt4 book ai didi

java - 我该如何修复这个错误?需要双,双;发现双重;

转载 作者:行者123 更新时间:2023-12-01 17:59:54 25 4
gpt4 key购买 nike

public class Account{

//实例变量

private double balance;
private double interestRate;

//构造函数

public void Account(double initialBalance) {
if (balance < 0) {
balance = initialBalance;
}
}

public void Account() {
balance = 0.0;
}

//实例方法

public void withdraw(double amount) {
double backup = balance;
balance = balance - amount;
if (balance < 0) {
System.out.println("error");
balance = backup;
}
}

//提现使用的方法

public void deposit(double amount) {
balance = balance + amount;
if (balance >= 10000){
System.out.println("You are now rich");
}
}

public double getBalance() {
return balance;
}

public double setInterest(double rate){
interestRate = rate;
}

public double computeInterest (int n) {
double computeInterest = Math.pow(interestRate + balance * n);
return computeInterest;

}

//此方法包含错误,并表示它需要两个 double ,但只能//找到一个

public void close() {
balance = 0.0;
}

//关闭余额的方法

}

最佳答案

您仅向 computeInterest() 方法中的 Math.pow() 提供一个参数。需要两个 double 。

关于java - 我该如何修复这个错误?需要双,双;发现双重;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41836125/

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