Question: Integer arrays firstArray and secondArray are read from input, each containing four elements. If an element in firstArray is less than or equal to the
Integer arrays firstArray and secondArray are read from input, each containing four elements. If an element in firstArray is less than or equal to the corresponding element in secondArray then replace the element in firstArray with Otherwise, add to the element in firstArray.
Ex: If the input is:
then the output is:
import java.util.Scanner;
public class ArrayComparison
public static void mainString args
Scanner scnr new ScannerSystemin;
final int NUMVALS ;
int firstArray new intNUMVALS;
int secondArray new intNUMVALS;
int i;
for i ; i NUMVALS; i
firstArrayi scnrnextInt;
for i ; i NUMVALS; i
secondArrayi scnrnextInt;
Your code goes here
for i ; i firstArray.length; i
System.out.printfirstArrayi;
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
