![]() ** Doubles the first 5 elements of the array */įor (int i = 0 i < values. What will the following code print out? Can you write a similar method called tripleFirstFour() that triples the first 4 elements of the array? Make sure you test it in main. Joe, a production worker in a doll manufacturing plant, recently changed positions on the manufacturing line from painting the eyes, to attaching arms to each doll. It is created in the constructor and changed or accessed by the methods. Notice that it uses a complex conditional ( &) on line 14 to make sure that the loop doesn’t go beyond the length of the array, because if you had an array that had less than 5 elements, you wouldn’t want the code to try to double the 5th element which doesn’t exist! Notice that in this code, the array is a private instance variable of the class ArrayWorker. The following code doubles the first five elements in an array. You can loop through just some of the elements of an array using a for loop. You don’t have to loop through all of the elements of an array. Question 7 2 out of 2 points Scenario B Joe, a production worker in a doll manufacturing plant, recently changed positions on the manufacturing line from painting the eyes to attaching arms to each doll. You must start at the length of the array minus one. You can not start the index at the length of the array.The average salary for this role is 38,119 per year or 16.34 per hour. Experience is the key indicator of salary, with employers paying highly experienced production employees more than entry-level employees. The method will only return -1 if no value in the array is less than the passed value. Production workers receive a salary based on their relevant experience, location and employers discretion.You can also follow it in the visualizer by clicking on the Show Code Lens button. What do you think the following code will print out? First trace through it on paper keeping track of the array and the index variable.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |