Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用孔隙参数_Java - Fatal编程技术网

Java 使用孔隙参数

Java 使用孔隙参数,java,Java,有些事情我一次又一次地试图解决,但我做不到 因此,程序要求用户输入3个数字,然后要求用户输入他们想要添加的百分比,然后这些数字进入一个void方法: 所以它是这样的: public static void main(String[] args) { System.out.print("Number 1: "); X1 = s.nextLong(); System.out.print("Number 2: "); W1 = s.ne

有些事情我一次又一次地试图解决,但我做不到

因此,程序要求用户输入3个数字,然后要求用户输入他们想要添加的百分比,然后这些数字进入一个void方法:

所以它是这样的:

public static void main(String[] args) {

        System.out.print("Number 1: ");
        X1 = s.nextLong();
        System.out.print("Number 2: ");
        W1 = s.nextLong();
        System.out.print("Number 3: ");
        Z1 = s.nextLong();

        System.out.print("Percentage 1: ");
        int a = s.nextInt();
        System.out.print("Percentage 2: ");
        int b = s.nextInt();
        System.out.print("Percentage 3: ");
        int c = s.nextInt();
        Number(a,b,c);

}

public static void Number(int a, int b, int c)
{

    X1 = (long) (X1*(a/100 + 1));
    W1 = (long) (W1*(b/100 + 1));
    Z1 = (long) (Z1*(c/100 + 1));

}
但是如果我尝试输入结果,数字不会改变

注:X1、W1和Z1均用作静态长


除非a,b,c>=100,否则表达式

a/100 
将是0。因此

something * (a/100 +1) 


使用数字法将数字除以100.0。

您正在使用整数算法将整数参数除以整数
100
,如果值小于
100
,则会得到
0
。使用
100.0
强制浮点精度

X1 = (long) (X1*(a / 100.0 + 1.0));
...

publicstaticvoidnumber(inta,intb,intc){
-这不是Javascript。试试Java,你是如何输出结果的?X1,W1和Z1是如何定义的?我没有编写整个程序,这是它的一部分(没有定义的变量和导入),我得到了答案,谢谢
X1 = (long) (X1*(a / 100.0 + 1.0));
...