Answered step by step
Verified Expert Solution
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 lengthsize of the array will be determined by the variable size. ie if the value passed in for the variable size is the array will have a length of fillAndCopy The method will fill the array with random values between and 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 For example, if the array has the following set of values: the print method would print the following: The array has values that are divisible by 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 If the User's input is valid use it as the size to create a LetsPlayWithArrays object.
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 lengthsize of the array will be determined by the variable size. ie if the value passed in for the variable size is the array will have a length of
fillAndCopy The method will fill the array with random values between and 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 For example, if the array has the following set of values:
the print method would print the following:
The array has values that are divisible by
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started