Question: Integer numValues is read from input, representing the number of integers to be read next. Then, the remaining integers are read and stored into array
Integer numValues is read from input, representing the number of integers to be read next. Then, the remaining integers are read and stored into array wagesList. Initialize the array halfList to be half the size of wagesList. Write a loop that iterates through halfList and:
If the corresponding element in the first half of wagesList is greater than then assign the element in halfList with
Otherwise, assign the element in halfList with the corresponding element in the first half of wagesList.
Ex: If the input is:
then the output is:
Original wages:
First half of the wages:
Note: Input array always has an even number of elements.
import java.util.Scanner;
public class Wage
public static void mainString args
Scanner scnr new ScannerSystemin;
int wagesList;
int halfList;
int numValues;
int i;
numValues scnrnextInt;
wagesList new intnumValues;
for i ; i wagesList.length; i
wagesListi scnrnextInt;
Your code goes here
System.out.printOriginal wages: ;
for i ; i wagesList.length; i
System.out.printwagesListi;
System.out.println;
System.out.printFirst half of the wages: ;
for i ; i halfList.length; i
System.out.printhalfListi;
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
