【发布时间】:2014-11-23 18:01:32
【问题描述】:
所以我在第 18 行遇到了一个错误,它描述了:
HelloWorld.java:18: error: method calcThirdChance in class HelloWorld cannot be applied to given types;
int t3 = calcThirdChance(t1+t2);
^
required: int,int
found: int
reason: actual and formal argument lists differ in length
这对我来说意义不大,因为方法 calcThirdChance 返回一个 int,而我在该行中只声明一个 int,因此我不知道为什么它需要 2 个 int,据称这是错误的原因。
public class HelloWorld{
public static void main(String []args){
System.out.println(simMin(70,80));
}
public static int calcThirdChance(int t1, int t2){
int c;
c = -1*(t1+t2);
double finalsend;
finalsend = Math.pow(2.71, c/100)*2;
finalsend*=150;
return (int)finalsend;
}
public static int simMin(int t1, int t2){
int t3 = calcThirdChance(t1+t2);
int total=t1+t2+t3;
int play = 50;
if(play<=t1){
return t1;
}
else if(play<=t1+t2){
return t2;
}
else{
return t3;
}
}
}
【问题讨论】:
标签: java class methods int declaration