gpt4 book ai didi

java - (double,int) 不能应用于 (double)

转载 作者:行者123 更新时间:2023-12-02 08:05:58 25 4
gpt4 key购买 nike

我绞尽脑汁想弄清楚这个问题。

我的主要方法是:

public static void main(String [] args)
{
double payRate;
double grossPay;
double netPay;
int hours;

Scanner input = new Scanner(System.in);

System.out.println("Welcome to the Pay Roll Program");

printDescription();

System.out.print("Please input the pay per hour: ");
payRate = input.nextDouble();

System.out.println("\nPlease input the pay per hour: ");
hours = input.nextInt();
System.out.println("\n");


netPay = computePaycheck(netPay);

System.out.println("The net pay is $" + (netPay));
System.out.println("We hope you enjoyed this program");

System.exit(0);

以及计算netPay的方法

public static double computePaycheck(double payRate, int hours)
{


double grossPay = computePaycheck(payRate*hours);

double netPay = (grossPay - (grossPay *.15));

return netPay;

}

但我收到错误“PayCheck 中的computePaycheck(double,int) 无法应用于 (double)”

我有点理解这一点,但我无法找到补救办法。

最佳答案

1) 您正在调用一个具有 2 个参数的函数,但只传递 1 个参数。这将导致编译错误。

2)当您从自身内部调用computePaycheck时,这将循环并导致堆栈溢出。

关于java - (double,int) 不能应用于 (double),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8162334/

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