import java.util.Random;
import java.util.Scanner;
public class Carpim {
Scanner input = new Scanner(System.in);
Random myRandom = new Random();
public void determine(){
int trueNumber = 0;
int wrongNumber = 0;
int total = 0;
int answer = 0;
for (int i = 0; i < 5; ++i){
int num1 = 1 + myRandom.nextInt(11);
int num2 = 1 + myRandom.nextInt(11);
int correctResult = num1 * num2;
System.out.println( num1 + "*" + num2 + " What is the answer?");
answer = input.nextInt();
if (answer == correctResult){
++trueNumber;
++total;
}else if (answer != trueNumber){
++total;
++wrongNumber;
}//end if statement
}//end for loop
percentage(total, wrongNumber);
}//end method
private int percentage(int total, int wrongNumber){
int percentage = (total - wrongNumber)/total;
System.out.println(total + " " + wrongNumber + " " + percentage );
return percentage;
}//end private method.
}//End Class
这是我的代码,当我运行此代码时,最后无法计算百分比。但是,它可以计算出 wrongNumber 和总数。你能帮我看看这段代码有什么问题吗?