小编pro*_*odo的帖子

将数组中的所有元素乘以外部数字?

我需要将数组中的所有值乘以 3000,这又会创建一个新数组,我将使用该数组从另一个数组中减去。我试图创建一个单独的方法来为我做这件事,但我在乘法数组中得到的只是一堆奇怪的数字和符号?

这是我写的代码

public static void main(String[] args)
{    
    int numberOfTaxpayers = Integer.parseInt(JOptionPane.showInputDialog("Enter how many users you would like to calculate taxes for: ");
    int[] usernumChild = new int[numberOfTaxPayers];
    for (int i = 0; i < usernumChild.length; i++)
    {
        usernumChild[i] = Integer.parseInt(JOptionPane.showInputDialog("Enter number of children for user "+ (i+1) +": "));
    }//this for loop finds out the number of children per user so we can later multiply each input by 3000 to create an array that determine dependency exemption for …
Run Code Online (Sandbox Code Playgroud)

java arrays methods

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

arrays ×1

java ×1

methods ×1