Java Reference
In-Depth Information
9. Write a program to test the insertion sort algorithm as given in this chapter.
10. Write a version of the insertion sort algorithm that can be used to sort a
string Vector object. Also, write a program to test your algorithm.
11. Write a version of a binary search that can be used to search a string Vector
object. Also, write a program to test your algorithm. (Use the selection sort
algorithm you developed in Programming Exercise 8 to sort the Vector.)
12. Redo the Programming Example Election Results so that the names of the
candidates and the total votes are stored in Vector objects.
13. Write a program to keep track of a hardware store's inventory. The store
sells various items. For each item in the store, the following information is
kept: item ID, item name, number of pieces ordered, number of pieces
currently in the store, number of pieces sold, manufacturer's price of the
item, and the store's selling price. At the end of each week, the store
manager would like to see a report in the following form:
Friendly Hardware Store
itemID itemName
pOrdered
pInStore pSold manufPrice sellingPrice
4444
Circular Saw
150
150
40
45.00
125.00
3333
Cooking Range
50
50
20
450.00
850.00
.
.
.
Total Inventory: $#########.##
Total number of items in the store: ___________
The total inventory is the total selling value of all the items currently in the
store. The total number of items is the sum of the number of pieces of all
the items in the store.
Your program must be menu driven, giving the user various choices, such
as: check whether an item is in the store, sell an item, and print the report.
After inputting the data, sort it according to the items' names. Also, after an
item is sold, update the appropriate counts.
Initially, the number of pieces (of an item) in the store is the same as the
number of pieces ordered, and the number of pieces of an item sold is zero.
Input to the program is a file consisting of data in the following form:
itemID
itemName
pOrdered manufPrice sellingPrice
Use seven parallel vectors to store the information. The program must
contain at least the following methods—a method to input the data into
the vectors, a method to display the menu, a method to sell an item, and a
method to print the report for the manager. After inputting the data, sort it
according to the items' names.
1
4
Search WWH ::




Custom Search