Question: Integer arrays originalArray and cleaningArray are read from input, each containing four elements. If an element in originalArray is negative, then replace the element in
Integer arrays originalArray and cleaningArray are read from input, each containing four elements. If an element in originalArray is negative, then replace the element in originalArray with the corresponding element in cleaningArray which has only positive integers Ex: If the input is: then the output is: import java.util.Scanner; public class ReplaceNegatives public static void mainString args Scanner scnr new ScannerSystemin; final int NUMVALS ; int originalArray new intNUMVALS; int cleaningArray new intNUMVALS; int i; for i ; i NUMVALS; i originalArrayi scnrnextInt; for i ; i NUMVALS; i cleaningArrayi scnrnextInt; for i ; i originalArray.length; i System.out.printoriginalArrayi; System.out.println;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
