This exercise includes a starter.java file. Use the starter file to write your program but make...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
This exercise includes a starter.java file. Use the starter file to write your program but make sure you do make changes ONLY in the area of the starter file where it is allowed, between the following comments: //#######your code starts here. //#######your code ends here if you modify the starter file anywhere else the Test will fail. Write a class called Increment Each Element containing a main method. Use the starter provided to create a reference to firstArray called reference and a copy of firstArray called copy. The starter declares the names firstArray, reference, and copy. just need to assign the appropriate array to each name. Then the starter calls the method incr which increments each element of each array by 1. Then the three arrays are printed. You cannot use the method Arrays.copyOf. examples % java IncrementEachElement 1 2 3 4 5 firstArray: [2, 3, 4, 5, 6] secondArray: [2, 3, 4, 5, 6] % java IncrementEach Element 0 firstArray: [1] secondArray: [1] % java IncrementEach Element 3579 firstArray: [4, 6, 8, 10] secondArray: [4, 6, 8, 10] //my version import java.util.*; public class IncrementEachElement { } public static int [] readArray(){ String ss = input.nextLine(); String [] aa = ss.split("[, ]"); int[] int_array = new int [aa. length]; if (aa [0]. length() == 0){ } //System.out.println("" + Arrays.toString(int_array)); int_array = new int [0]; return int_array; } // int ii = 0; for (String str: aa) { } int_array[ii++] = Integer.parseInt(str); } public static void incr(int [] aa) { } return int_array; for (int x = 0; x < aa.length; x++){ aa[x] = aa[x] + 1; } static Scanner input = new Scanner(System.in); public static void main (String[] args) { int [] firstArray; int [] reference; int[] copy; firstArray = readArray(); //#######your code starts here. //create a reference (or alias) to firstArray called "reference" //create a copy of firstArray called "copy" //#######your code ends here //the method incr adds 1 to each element of the array incr(firstArray); incr(reference); incr(copy); System.out.println("firstArray: " + Arrays.toString(firstArray)); System.out.println("reference: + Arrays.toString(reference)); System.out.println("copy: " + Arrays.toString(copy)); This exercise includes a starter.java file. Use the starter file to write your program but make sure you do make changes ONLY in the area of the starter file where it is allowed, between the following comments: //#######your code starts here. //#######your code ends here if you modify the starter file anywhere else the Test will fail. Write a class called Increment Each Element containing a main method. Use the starter provided to create a reference to firstArray called reference and a copy of firstArray called copy. The starter declares the names firstArray, reference, and copy. just need to assign the appropriate array to each name. Then the starter calls the method incr which increments each element of each array by 1. Then the three arrays are printed. You cannot use the method Arrays.copyOf. examples % java IncrementEachElement 1 2 3 4 5 firstArray: [2, 3, 4, 5, 6] secondArray: [2, 3, 4, 5, 6] % java IncrementEach Element 0 firstArray: [1] secondArray: [1] % java IncrementEach Element 3579 firstArray: [4, 6, 8, 10] secondArray: [4, 6, 8, 10] This exercise includes a starter.java file. Use the starter file to write your program but make sure you do make changes ONLY in the area of the starter file where it is allowed, between the following comments: //#######your code starts here. //#######your code ends here if you modify the starter file anywhere else the Test will fail. Write a class called Increment Each Element containing a main method. Use the starter provided to create a reference to firstArray called reference and a copy of firstArray called copy. The starter declares the names firstArray, reference, and copy. just need to assign the appropriate array to each name. Then the starter calls the method incr which increments each element of each array by 1. Then the three arrays are printed. You cannot use the method Arrays.copyOf. examples % java IncrementEachElement 1 2 3 4 5 firstArray: [2, 3, 4, 5, 6] secondArray: [2, 3, 4, 5, 6] % java IncrementEach Element 0 firstArray: [1] secondArray: [1] % java IncrementEach Element 3579 firstArray: [4, 6, 8, 10] secondArray: [4, 6, 8, 10] This exercise includes a starter.java file. Use the starter file to write your program but make sure you do make changes ONLY in the area of the starter file where it is allowed, between the following comments: //#######your code starts here. //#######your code ends here if you modify the starter file anywhere else the Test will fail. Write a class called Increment Each Element containing a main method. Use the starter provided to create a reference to firstArray called reference and a copy of firstArray called copy. The starter declares the names firstArray, reference, and copy. just need to assign the appropriate array to each name. Then the starter calls the method incr which increments each element of each array by 1. Then the three arrays are printed. You cannot use the method Arrays.copyOf. examples % java IncrementEachElement 1 2 3 4 5 firstArray: [2, 3, 4, 5, 6] secondArray: [2, 3, 4, 5, 6] % java IncrementEach Element 0 firstArray: [1] secondArray: [1] % java IncrementEach Element 3579 firstArray: [4, 6, 8, 10] secondArray: [4, 6, 8, 10] This exercise includes a starter.java file. Use the starter file to write your program but make sure you do make changes ONLY in the area of the starter file where it is allowed, between the following comments: //#######your code starts here. //#######your code ends here if you modify the starter file anywhere else the Test will fail. Write a class called Increment Each Element containing a main method. Use the starter provided to create a reference to firstArray called reference and a copy of firstArray called copy. The starter declares the names firstArray, reference, and copy. just need to assign the appropriate array to each name. Then the starter calls the method incr which increments each element of each array by 1. Then the three arrays are printed. You cannot use the method Arrays.copyOf. examples % java IncrementEachElement 1 2 3 4 5 firstArray: [2, 3, 4, 5, 6] secondArray: [2, 3, 4, 5, 6] % java IncrementEach Element 0 firstArray: [1] secondArray: [1] % java IncrementEach Element 3579 firstArray: [4, 6, 8, 10] secondArray: [4, 6, 8, 10] This exercise includes a starter.java file. Use the starter file to write your program but make sure you do make changes ONLY in the area of the starter file where it is allowed, between the following comments: //#######your code starts here. //#######your code ends here if you modify the starter file anywhere else the Test will fail. Write a class called Increment Each Element containing a main method. Use the starter provided to create a reference to firstArray called reference and a copy of firstArray called copy. The starter declares the names firstArray, reference, and copy. just need to assign the appropriate array to each name. Then the starter calls the method incr which increments each element of each array by 1. Then the three arrays are printed. You cannot use the method Arrays.copyOf. examples % java IncrementEachElement 1 2 3 4 5 firstArray: [2, 3, 4, 5, 6] secondArray: [2, 3, 4, 5, 6] % java IncrementEach Element 0 firstArray: [1] secondArray: [1] % java IncrementEach Element 3579 firstArray: [4, 6, 8, 10] secondArray: [4, 6, 8, 10] This exercise includes a starter.java file. Use the starter file to write your program but make sure you do make changes ONLY in the area of the starter file where it is allowed, between the following comments: //#######your code starts here. //#######your code ends here if you modify the starter file anywhere else the Test will fail. Write a class called Increment Each Element containing a main method. Use the starter provided to create a reference to firstArray called reference and a copy of firstArray called copy. The starter declares the names firstArray, reference, and copy. just need to assign the appropriate array to each name. Then the starter calls the method incr which increments each element of each array by 1. Then the three arrays are printed. You cannot use the method Arrays.copyOf. examples % java IncrementEachElement 1 2 3 4 5 firstArray: [2, 3, 4, 5, 6] secondArray: [2, 3, 4, 5, 6] % java IncrementEach Element 0 firstArray: [1] secondArray: [1] % java IncrementEach Element 3579 firstArray: [4, 6, 8, 10] secondArray: [4, 6, 8, 10] //my version import java.util.*; public class IncrementEachElement { } public static int [] readArray(){ String ss = input.nextLine(); String [] aa = ss.split("[, ]"); int[] int_array = new int [aa. length]; if (aa [0]. length() == 0){ } //System.out.println("" + Arrays.toString(int_array)); int_array = new int [0]; return int_array; } // int ii = 0; for (String str: aa) { } int_array[ii++] = Integer.parseInt(str); } public static void incr(int [] aa) { } return int_array; for (int x = 0; x < aa.length; x++){ aa[x] = aa[x] + 1; } static Scanner input = new Scanner(System.in); public static void main (String[] args) { int [] firstArray; int [] reference; int[] copy; firstArray = readArray(); //#######your code starts here. //create a reference (or alias) to firstArray called "reference" //create a copy of firstArray called "copy" //#######your code ends here //the method incr adds 1 to each element of the array incr(firstArray); incr(reference); incr(copy); System.out.println("firstArray: " + Arrays.toString(firstArray)); System.out.println("reference: + Arrays.toString(reference)); System.out.println("copy: " + Arrays.toString(copy)); //my version import java.util.*; public class IncrementEachElement { } public static int [] readArray(){ String ss = input.nextLine(); String [] aa = ss.split("[, ]"); int[] int_array = new int [aa. length]; if (aa [0]. length() == 0){ } //System.out.println("" + Arrays.toString(int_array)); int_array = new int [0]; return int_array; } // int ii = 0; for (String str: aa) { } int_array[ii++] = Integer.parseInt(str); } public static void incr(int [] aa) { } return int_array; for (int x = 0; x < aa.length; x++){ aa[x] = aa[x] + 1; } static Scanner input = new Scanner(System.in); public static void main (String[] args) { int [] firstArray; int [] reference; int[] copy; firstArray = readArray(); //#######your code starts here. //create a reference (or alias) to firstArray called "reference" //create a copy of firstArray called "copy" //#######your code ends here //the method incr adds 1 to each element of the array incr(firstArray); incr(reference); incr(copy); System.out.println("firstArray: " + Arrays.toString(firstArray)); System.out.println("reference: + Arrays.toString(reference)); System.out.println("copy: " + Arrays.toString(copy)); //my version import java.util.*; public class IncrementEachElement { } public static int [] readArray(){ String ss = input.nextLine(); String [] aa = ss.split("[, ]"); int[] int_array = new int [aa. length]; if (aa [0]. length() == 0){ } //System.out.println("" + Arrays.toString(int_array)); int_array = new int [0]; return int_array; } // int ii = 0; for (String str: aa) { } int_array[ii++] = Integer.parseInt(str); } public static void incr(int [] aa) { } return int_array; for (int x = 0; x < aa.length; x++){ aa[x] = aa[x] + 1; } static Scanner input = new Scanner(System.in); public static void main (String[] args) { int [] firstArray; int [] reference; int[] copy; firstArray = readArray(); //#######your code starts here. //create a reference (or alias) to firstArray called "reference" //create a copy of firstArray called "copy" //#######your code ends here //the method incr adds 1 to each element of the array incr(firstArray); incr(reference); incr(copy); System.out.println("firstArray: " + Arrays.toString(firstArray)); System.out.println("reference: + Arrays.toString(reference)); System.out.println("copy: " + Arrays.toString(copy)); //my version import java.util.*; public class IncrementEachElement { } public static int [] readArray(){ String ss = input.nextLine(); String [] aa = ss.split("[, ]"); int[] int_array = new int [aa. length]; if (aa [0]. length() == 0){ } //System.out.println("" + Arrays.toString(int_array)); int_array = new int [0]; return int_array; } // int ii = 0; for (String str: aa) { } int_array[ii++] = Integer.parseInt(str); } public static void incr(int [] aa) { } return int_array; for (int x = 0; x < aa.length; x++){ aa[x] = aa[x] + 1; } static Scanner input = new Scanner(System.in); public static void main (String[] args) { int [] firstArray; int [] reference; int[] copy; firstArray = readArray(); //#######your code starts here. //create a reference (or alias) to firstArray called "reference" //create a copy of firstArray called "copy" //#######your code ends here //the method incr adds 1 to each element of the array incr(firstArray); incr(reference); incr(copy); System.out.println("firstArray: " + Arrays.toString(firstArray)); System.out.println("reference: + Arrays.toString(reference)); System.out.println("copy: " + Arrays.toString(copy)); //my version import java.util.*; public class IncrementEachElement { } public static int [] readArray(){ String ss = input.nextLine(); String [] aa = ss.split("[, ]"); int[] int_array = new int [aa. length]; if (aa [0]. length() == 0){ } //System.out.println("" + Arrays.toString(int_array)); int_array = new int [0]; return int_array; } // int ii = 0; for (String str: aa) { } int_array[ii++] = Integer.parseInt(str); } public static void incr(int [] aa) { } return int_array; for (int x = 0; x < aa.length; x++){ aa[x] = aa[x] + 1; } static Scanner input = new Scanner(System.in); public static void main (String[] args) { int [] firstArray; int [] reference; int[] copy; firstArray = readArray(); //#######your code starts here. //create a reference (or alias) to firstArray called "reference" //create a copy of firstArray called "copy" //#######your code ends here //the method incr adds 1 to each element of the array incr(firstArray); incr(reference); incr(copy); System.out.println("firstArray: " + Arrays.toString(firstArray)); System.out.println("reference: + Arrays.toString(reference)); System.out.println("copy: " + Arrays.toString(copy)); //my version import java.util.*; public class IncrementEachElement { } public static int [] readArray(){ String ss = input.nextLine(); String [] aa = ss.split("[, ]"); int[] int_array = new int [aa. length]; if (aa [0]. length() == 0){ } //System.out.println("" + Arrays.toString(int_array)); int_array = new int [0]; return int_array; } // int ii = 0; for (String str: aa) { } int_array[ii++] = Integer.parseInt(str); } public static void incr(int [] aa) { } return int_array; for (int x = 0; x < aa.length; x++){ aa[x] = aa[x] + 1; } static Scanner input = new Scanner(System.in); public static void main (String[] args) { int [] firstArray; int [] reference; int[] copy; firstArray = readArray(); //#######your code starts here. //create a reference (or alias) to firstArray called "reference" //create a copy of firstArray called "copy" //#######your code ends here //the method incr adds 1 to each element of the array incr(firstArray); incr(reference); incr(copy); System.out.println("firstArray: " + Arrays.toString(firstArray)); System.out.println("reference: + Arrays.toString(reference)); System.out.println("copy: " + Arrays.toString(copy));
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Discuss which organizational structure (i.e. functional, product-market divisional, matrix) you would recommend Guelph General Hospital implement, assuming the hospital moves forward with the...
-
Identify the type I error and the type II error that correspond to the given hypothesis. The percentage of households with Internet access is greater than 60%. B. Fail to reject the null hypothesis...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
What is the "ALDI Way" and what was its quest? Take out costs; eliminate complexity Survival; make enough money to pay overhead costs Increase market share; find more prospective customers Build...
-
Find the standard matrix for the linear operator T: R3 R3 that maps a point (x, y, z) into Its reflection through the xz-plane
-
Consider the mouse in the following maze from Section 10.1, Exercise 19. Data From Section 10.1 Exercise 19 If the mouse starts in room 1, how many steps on average will it take the mouse to get to...
-
Describe or define the four basic financial statements: 1. Income statement 2. Balance sheet 3. Statement of shareholders equity 4. Statement of cash flow Discuss how the four statements are...
-
The average life expectancy for Bostonians is 78.1 years (The Boston Globe, August 16, 2010). Assume that this average was based on a sample of 50 Bostonians and that the population standard...
-
Appling Enterprises issued 8% bonds with a face amount of $460,000 on January 1, 2024. The bonds sold for $417,676 and mature in 2043 (20 years). For bonds of similar risk and maturity the market...
-
George Pharmacy is a pharmaceutical salesman who has been very successful at his job in the last few years. Unfortunately, his family life has not been very happy. Three years ago, his only child,...
-
When a bond s coupon rate exceeds its yield to maturity, the bond will: Question 1 9 options: sell for less than par value. sell for more than par value. decrease its coupon rate. increase its coupon...
-
The Salvation Army is being sued because of an accident that occurring during a Salvation Army summer camp in which a child in the camp nearly drowned. After the accident, the Salvation Army...
-
Insurance expired during the year is $7,300. Supplies remaining on hand at the end of the year equal $3,200. Provide services of $12,100 related to cash paid in advance by customers. Require......
-
The problem-oriented medical record (POMR) was developed by Dr.Lawrence L. Weed. The POMR is based on the client\'s problems, andevery health-care employee, including the provider, adds to thechart...
-
7(a) Find the radial and transverse components of the velocity of a particle moving along the curve ax2 +by2 =1 at any time t if the polar angle = ct2. 9 (b) A particle is projected vertically...
-
BIO Ions on cell walls The membrane of a body cell has a positive ion of charge on the outside wall and a negative ion of charge on the inside wall. Determine the magnitude of the electrical force...
-
Two forces F and F2 act on an object of mass 4.80 kg. F = 35.0 N and F2 = 16.0 N. Find the acceleration of the object for the configuration of forces shown in the following figure. F2 m 60.0 F
-
The following items were displayed in the statement of affairs for Lubbock Company: Fully secured liabilities ......... $90,000 Partially secured liabilities ....... 12,000 Unsecured liabilities...
-
Ken paid the following amounts for interest during 2012: Qualified interest on home mortgage...........................................$4,700 Auto loan...
-
Yolanda earns $112,000 in 2012. Calculate the FICA tax that must be paid by: Yolanda:.....................Soc.Sec..................$__________...
-
For each of the following situations, indicate whether the taxpayer(s) is (are) required to file a tax return for 2012. Explain your answer. a. Helen is a single taxpayer with interest income in 2012...
-
North Company's income statement and comparative balance sheets as of December 31 of 2019 and 2018 follow: During 2019, North sold land for \(\$ 70,000\) cash that had originally cost \(\$ 45,000\)....
-
The Pruitt Company's income statement and comparative balance sheets as of December 31 of 2019 and 2018 follow: During the year, the company sold for \(\$ 15,000\) cash old equipment that had cost...
-
The Sky Company's income statement and comparative balance sheets as of December 31 of 2019 and 2018 follow: During the year, the following transactions occurred: 1. Sold long-term investments...
Study smarter with the SolutionInn App