Question: Details create a Stock class containing two data fields: stockName ( a string ) , and stockPrice ( a double ) . and implementing the
Details
create a Stock class containing two data fields: stockName a string and stockPrice a double and implementing the Comparable interface check
Java API Write the appropriate getter and setter methods, as well as the toString, equals, and compareTo methods. The equals methods returns true if
two Stock objects have the same name and price, otherwise false. The compareTo method takes a Stock object as argument and returns an positive
integer if the calling object's price is greater than the argument object's stock price, if the two stocks have the same price, otherwise a negative
integer.
Demonstrate the Stock class in a program to:
create an array of elements. Each element is a Stock object
sort the array in ascending order based on the stock price using any sorting algorithm. You need to rewrite the sorting algorithm to make it work on
object sorting.
ask the user to enter a stock name and price.
search the array using sequential search or binary search for that stock
Analyze the worstcase time complexity for sorting an array of Stock objects and searching a stock in the array. Suppose the problem size the array
size is n
Requirements:
program should be welldocumented
time efficiency analysis should be typed in a txt or docx file. Upload the file
Submit the
repl.it link of the program
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
