Мне нужно несколько всех значений в массиве 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 each user
int[] depndExemp = multiply(usernumChild, 3000);//this was the calling of the multiply method... somewhere here is the error!!
}//end main method
public static int[] multiply(int[] children, int number)
{
int array[] = new int[children.length];
for(int i = 0; i < children.length; i++)
{
children[i] = children[i] * number;
}//end for
return array;
}//this is the method that I was shown in a previous post on how to create return an array in this the dependency exemption array but when I tested this by printing out the dependency array all I received were a jumble of wrong numbers.
Что вы имеете в виду под «новый массив, который я буду использовать, чтобы вычесть из другого массива»? –
@ Lutz Horn Я еще не включил эту часть, но мне нужно будет сделать массив зависимостей (умножая детей на 3000 для каждого ввода), а затем вычесть из другого массива, который содержит валовой доход для каждого пользователя, который будет приводят к созданию другого массива под чистым доходом ... по какой-то причине наш инструктор хочет получить массив для каждого типа данных – prodo