(Solved) : Write Method Called Splitarray Receive Four Parameters Follows Original Array Array Multip Q42700976 . . .

Write a method called splitArray which will receive fourparameters as follows:

  • Original array
  • Array of multiples
  • Array of not multiples
  • Number to compare if the values within the original array aremultiples of

Assuming that always the original array will contain half valuesas multiples and half as not multiples. Your method should returnthe numbers within the original array that are multiples of thelast parameter in the array of multiples (second parameter).Furthermore, your method should return the array of not multiplesin the third parameter received.

As an example, if the input was 6 7 8 9 3 6 10 3. The Array ofmultiples would be conformed as 9 3 6 and the array of notmultiples would be conformed by 7 8 10. And the output should be asfollows.

Multiple[0] = 9Multiple[1] = 3Multiple[2] = 6Not multiple[0] = 7Not multiple[1] = 8Not multiple[2] = 10

Keep in mind that you will create the other arrays and they willstart without having any element

import java.util.*;

public class Main{

public static void splitArray(int[] ori, int[] mul, int[] not, intval){
  
// Fill your multiple and not multiple arrays here based on theoriginal array
  
}

public static void main(String[] args){
  
Scanner scnr = new Scanner(System.in);
  
int oSize = scnr.nextInt();
  
int[] original = new int[oSize]; // Declaring the originalarray
int[] multiple = new int[oSize/2]; // Declaring the array ofmultiple numbers
int[] notMultiple = new int[oSize/2]; // Declaring the array of notmultple numbers
int value;
  
  
// Getting the values for the original array
for (int i = 0; i < oSize; i++){
original[i] = scnr.nextInt();
}
  
value = scnr.nextInt();
  
splitArray(original, multiple, notMultiple, value);
  
for (int i = 0; i < oSize / 2; i++){
System.out.printf(“Multiple[%d] = %d%n”, i, multiple[i]);
}

for (int i = 0; i < oSize / 2; i++){
System.out.printf(“Not multiple[%d] = %d%n”, i,notMultiple[i]);
}
  
}

}

Expert Answer


Answer to Write a method called splitArray which will receive four parameters as follows: Original array Array of multiples Array …

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?