Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE ANSWER IM DESPSERATE!! Code using Java NetBeans. boolean contains ( int num ) method that Tests whether Scores class contains the number num. Returns

PLEASE ANSWER IM DESPSERATE!! Code using Java NetBeans. boolean contains (int num) method that Tests whether Scores class
contains the number num. Returns true when the num is contained in Scores class.
void add (int num) method that always adds to the "next available" slot in
the array.
This method should add a new number to the end of the list (i.e. the next open
slot in list).
Restrictions:
Unless directed otherwise, you cannot use any Java class libraries in this
assignment. In particular, you cannot use the Arraylist class nor can you use
any methods from the Arrays class.
If needed:
you may create and use one or more instances of an array and access the
length instance variable for each array.
you may NOT access any other methods from the Arrays class.
you may use the Java Random class.
you may NOT use the Math.Random class
Of course, you may use the System.print, println, and printf methods.
In this project you will be doing the following:
Create a NetBeans project using the naming convention Lab102-LastFM
Create a class named Scores that has the following properties:
an instance variable List - an array of int type: This structure will hold the numbers.
an instance variable count of int type: This will provide the count of numbers
currently stored in Scores class. This count will increment when a new number is added
to the list and decrement when a number is removed from the list
Provide a default constructor that will initialize the instance variable list to a new array
of length 2.
Provide an overloaded constructor that will take an int value as parameter and
initialize list to a new array of that length.
Implement the following methods:
int size() method that returns a count of numbers in Scores class
boolean isEmpty() method that checks if Scores class is empty, returns true
when empty
void clear () method that removes all the numbers from Scores class
int getFrequencyof (int num) method that returns a count the number
of times the number num exists in Scores class
Finally design a java cLass Client with the main () method that does the following:
Create an Object of Type Scores using the overloaded constructor and pass the value
Use a for loop to populate the list in Scores object with 32 random numbers between
-10 and +10 inclusive. (Use the Random class from java. util package to generate
pseudorandom numbers).
Call toString() to print the contents of the Scores object.
Call the add () method to add the number 6 to Scores object.
Print the current size of the list in the Scores object.
Call the remove () method to randomly remove a number from Scores class
Get the number at the 15th index position
Print the frequency of the number returned by the previous step occurs in Scores class
Call the appropriate overloaded remove method to remove the first occurrence of
number at the 15th index position from Scores class
Print the frequency that this number now occurs in Scores class
Check whether the array in Scores object contains the number 5
Use JavaDoc commenting styles in the Scores class and the Client (Review Section 1.9.4 in
the textbook). Make sure to provide a block comment at the top that provides description of
each class and a JavaDoc comment for each method.
Use in line commenting as needed.
Things to turn in:
Open a Microsoft Word document using the naming convention Lab102-
LastFM.docx
Copy and Paste the source code of the client class.
(make sure to use Ctrl+A to select all the source code of the program and
Ctrl +C to copy).
Copy and Paste the source code of the Scores class.
Copy and paste the output of the client program (i.e. the contents of the
console/terminal).
Export the NetBeans project to a zip archive.
Finally, on blackboard, submit your Word document and project zipped file as
two separate files in a single submission.
image text in transcribed

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

Students also viewed these Databases questions

Question

Explain the concept of double jeopardy.

Answered: 1 week ago