Computer Science Question

I need help completing this assignment.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

CS Assignment
Step #1
Start the development process by planning your data and program organization. Hardware items
are the core objects in the project, the corresponding class must have fields for the name, price,
and amount. Decide how you will create a new object and access its data.
Consider a UML diagram before programming the class. The table shows an example of the
UML diagram that you can use and modify. For example, you may need to add mutator methods.
You will need the toString() method to create a string with the full information about an object.
Such a string can be printed on the screen or processed in other ways when necessary.
Item
-name: String
-price: double
-amount: int
+Item (nm: String, pr: double, am: int):
+getName(): String
+getPrice(): double
+getAmount(): int
+toString(): String
Step #2
Advance the driver program by replacing the user’s input with the input from the text file. The
text file has no formatting. It can be created and modified by any text editor.
You can hardcode the file’s name in your source code. Generally, there are no requirements for
the text file extension, it could be .txt, .dat, .data, etc., or no extension at all. In this program,
please use the extension .txt for your data file.
You can keep your data in the file in the way “one record – one line” with a delimiter,
such as coma, slash, or other symbols, e.g., ,,
or in the way “one record – several lines,” e.g.,
.
The file must have at least 10 records. To create a text file according to the selected format, use
any text editor, for example, Notepad or TextEdit.
To read the text file, you can use either the Scanner class or the buffered stream (used in the
labs). For the “one record one line” format, please check the method useDelimiter() of the class
Scanner. For example, the useDelimiter(“,\\s*”) method sets the delimiter to a comma, allowing
for optional whitespace after the comma. You can read a one-line record value-by-value, then
you need to add the delimiter at the end of each record in the file. Alternatively, you can read a
one-line record as one string and take the values from the string.
After this step, your program must be able to read the data from the file and create objects.
Program a loop that reads the whole file and creates an object for each record in the file. For
debugging purposes, echo every new object to the console using the method toString().
Step#3
Use an array to keep and process data in your project. Instead of printing objects to the
console, save them in the array using the loop created in Step #2. Though the maximum size
of the array is given, the actual number of the inventory records in the file is not known. This
number must be counted while file reading and then used during the runtime. If the text file
has more than 100 records the rest must be ignored. Because this value must be available to
all methods in the driver program, it may be declared as a global variable1 or passed
as an argument. Note that Arraylist is not allowed.
Step#4
Create methods that Implement the following:
1. Show the full inventory on the screen.
2. Calculate the total value of the inventory – the sum of the products x < amount>. The
result must be shown in two decimal digits.
3. Show the inventory on the screen sorted from the lowest to the highest price.
4. Show the inventory on the screen sorted by the item’s name.
5. Find an item by name using binary search and show it on the screen.
For each method decide what are method’s parameters to receive and process and what is the
returning value if any.
Note that in your program (a) you need to compare private fields of an object, so accessor
methods are required while implementing algorithms, e.g., myArray[i].getPrice() >
myArray[i+1].getPrice() and (b) string fields must use string methods to compare, e.g.,
myArray[i].getName().compareTo(anotherString). Remember that binary search works only on a
sorted array.
Step#5
The last step for this project is creating a menu that provides the following options:
1. Show the inventory on the screen.
2. Calculate the value of the inventory.
3. Show the inventory on the screen sorted from the lowest to the highest price.
4. Show the inventory on the screen sorted by the item’s name.
5. Find an item by name using binary search and show it on the screen.
6. Quit the program
Make sure the incorrect choice is controlled by your program.

Still stressed with your coursework?
Get quality coursework help from an expert!