Java中的数学公式不返回值

时间:2015-01-21 03:51:24

标签: java math formula

我想把这个等式变成java上的公式: (2 *平+ 10)/ 250)的(攻击/防御碱+ 2)

enter image description here

然而,当我运行程序时,输入输入字符串后输出为0.0。为什么是这样?我该如何解决?

我的代码:

import java.util.Scanner;

public class DamageCalc{
public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    System.out.println("Please enter pokemon statistics:"); 

    s.next();
    int Type = s.nextInt();
    s.next();
    int level = s.nextInt();
    s.next();   
    int Attack= s.nextInt();
    s.next();
    int Defense = s.nextInt();
    s.next();
    int Base = s.nextInt();
    s.next();
    int STAB = s.nextInt();
    s.next();
    double Critical = s.nextDouble();
    s.next();
    double Random = s.nextDouble();
    s.close();

    {
    if ((level < 1) || (level > 99))
        throw new IllegalArgumentException("Level value is out of range");
}
    {
    if ((Attack < 0))
        throw new IllegalArgumentException("Attack value must be greater than 0");
}
    {
    if ((Defense < 0))
        throw new IllegalArgumentException("Defense value must be greater than 0");
}
    {
        if ((Base < 0))
            throw new IllegalArgumentException("Base value must be greater than 0");
    }

    double nonmod = ((2*level + 10)/250)*(Attack/Defense*Base + 2);

System.out.print(nonmod);


}    

}

谢谢

0 个答案:

没有答案