Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The project will consist of two Java classes. One class will be named LetsPlayWithArrays. The other class will be named Main and will contain the

The project will consist of two Java classes. One class will be named LetsPlayWithArrays. The other class will be named Main and will contain the main method and create an object from the LetsPlayWithArrays class.
The LetsPlayWithArrays class will consist of the following instance variables and methods:
-array: int[]
+LetsPlayWithArrays()- The constructor method will accept an int parameter named size.
It will initialize the array of int's and pass it to the fillAndCopy() method. The length/size of the array will be determined by the variable size. i.e. if the value passed in for the variable size is 5, the array will have a length of 5.
+fillAndCopy()- The method will fill the array with random values between 0 and 100. Once the array is full, copy all of the values into a new array. Pass the new array to the print() method.
+print()- The method will print all of the values in the array and will also print the total number of values that are divisible by 3. For example, if the array has the following set of values:
3269
the print() method would print the following:
3269
The array has 3 values that are divisible by 3.
The Main class will consist of the following:
It will prompt the User for the size of an array.
It should validate the User's input by ensuring it is not a negative number and not greater than 1000.
If the User's input is valid use it as the size to create a LetsPlayWithArrays object.

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 And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions