Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 3: This problem will deal with arrays and you will need to code several methods to manipulate the arrays. a.) Create a class called

Problem 3: This problem will deal with arrays and you will need to code several methods to manipulate the arrays.

a.) Create a class called Problem3

b.) Create an array instance variable named values to hold a list of integers

c.) Create a constructor. The constructor should have as an argument a integer array named v.

d.) Set the instance variable to v.

e.) Create a method called printForward. This is the same method you created in your last lab. You can simply copy and paste if you want.

f.) Create a method called printFiveAndNine to print the 5th and 9th elements of the array. The method does not return anything and does not have an argument. Print the values for the 5th and 9th elements. Use some type of identifier such as element 5 is:

g.) Create a method called set0 to set the elements of all even indexes to 0 and then call the printForward method. The method does not return anything and does not have any arguments.

h.) Create a method called compuetEvenOdd that will add all elements from an even index in one loop and subtract all odd indexes using a second loop. You will need a sum variable and print the resulting number. Print some type of identification such as computeEvenOdd is + sum.

Problem 4; Create a class called Problem3Tester (Reminder: all tester classes contain a main method)

a.) Import Scanner.

b.) Create a scanner object.

c.) Create an array of type int with 10 elements.

d.) Create a loop that will run from 0 to 9

e.) Inside the loop, prompt the use to enter an integer.

f.) Get the number from the user and store it in the array

g.) After the loop is complete, create a Problem3 object using the array as the argument.

h.) Call the method printForward

i.) Call the method printFiveAndNine

j.) Call the method computeEvenOdd

k.) Call the method set0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions