Question: Integer arrays originalArr and cleaning Arr are read from input, each containing three elements. If an element in cleaningArr is equal to 1, replace
Integer arrays originalArr and cleaning Arr are read from input, each containing three elements. If an element in cleaningArr is equal to 1, replace the corresponding element in original Arr with O. Otherwise, subtract 5 from the corresponding element in originalArr. Ex: If the input is: 45 23 32 34 23 1 then the output is: 40 18 0 1 import java.util.Scanner; 11111 423 in HN 2 3 public class ResetNumbers { 4 public static void main(String[] args) { Scanner scnr = new Scanner (System.in); final int NUM_VALS = 3; int[] originalArr = new int [NUM_VALS]; int[] cleaningArr = new int [NUM_VALS]; int i; 5 6 7 8 9 10 11 12 13 14 tu 15 16 17 for (i = 0; i < NUM_VALS; ++i) { originalArr[i] = scnr.nextInt (); } for (i = 0; i < NUM_VALS; ++i) { cleaningArr[i] = scnr.nextInt (); }
Step by Step Solution
3.42 Rating (152 Votes )
There are 3 Steps involved in it
import javautilScanner public class ResetNumbers public ... View full answer
Get step-by-step solutions from verified subject matter experts
