Question: Six integers are read from input and stored into the array myArray. Write a static method addNumToElements ( ) that takes an integer array parameter
Six integers are read from input and stored into the array myArray. Write a static method addNumToElements that takes an integer array parameter and adds to each element in the array.
Ex: If the input is then the output is:
Input array: Output array:
import java.util.Scanner;
public class ModifyArray
Your code goes here
public static void printArrint arr
int i;
for i ; i arr.length; i
System.out.printarri;
System.out.println;
public static void mainString args
Scanner scnr new ScannerSystemin;
final int NUMELEM ;
int myArray new intNUMELEM;
int i;
int userNum;
for i ; i myArray.length; i
myArrayi scnrnextInt;
System.out.printInput array: ;
printArrmyArray;
addNumToElementsmyArray;
System.out.printOutput array: ;
printArrmyArray;
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
