Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Main topics: Arrays Effective size Sentinel terminated arrays Sentinel values Ar

ID: 3716928 • Letter: M

Question

Main topics:

Arrays
Effective size
Sentinel terminated arrays Sentinel values
Arrays as parameters

Exercise

This lab is designed to give you practice working with arrays and sentinel values. A sentinel terminated array is one that has a ”special” value, in the type domain, which can not ”occur” naturally and signifies that the Effective Size of the array is the first index of the array whose element is equal to this special value.

Getting Started To start this exercise, you should

1. Open eclipse and start a new Java project named Lab11

2. Add a Class (named Lab11) to this project.

3. Cut the program from this document and paste (replacing everything) in the Eclipse editor window.

Lab11.Java

++eSize; }

}

Problem Description

For this exercise you will be using the Lab11.java file that you copied using the command above.

In this file, we have provided you with two methods, that simply print the elements of an array to the screen.

In this file, we have also provided you with two pre-initialized arrays.

• Your job is to:

Copy the file.

Read through the class code until you think you understand each of the methods provided.

Compile and run the program to see what does and what it is missing.

Uncomment all the code involving revArray().

Write a corresponding body for the method revArray(), in accordance with its heading

that has been provided and the description below.

– revArray()
A method that takes an array and its effective size as its parameters, and reverses the order of the elements in the array.
Note: This method must work with any input, not just the sample array given.

Compile and run your program to make sure your revArray() method is working.

Uncomment all the code involving doubArray().

Write a corresponding body for the function doubArray(), in accordance with its heading

that has been provided and the description below.

– doubArray()
A method that takes a sentinel terminated array of ints and doubles the value of all of its elements.
Note: The sentinel value for this array is zero. And again this method must work with any input, not just the sample array given.

Compile and run your program to make sure your doubArray() method is working.

Sample output

Explanation / Answer

Please find my code.

Output:


The sized array:
-51 -1 5 21 36 58 64 128 256 512

The same sized array reversed:
512 256 128 64 36 58 21 5 -1 -51

The sentinel terminated array:
1 3 5 7 11 13 17

The same sentinel terminated array doubled:
2 6 10 14 22 26 34


Process finished with exit code 0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote