Identify specific stocks as either taxable or not taxable

Assignment Help Data Structure & Algorithms
Reference no: EM131870374

Data Structures Programming Assignment: Hashing with Sets and Maps

Problem Scenario

The brokerage office was very impressed with your work from Assn 3. Nevertheless, the IT director at the office just received the latest "Java Geek Weekly", and read all about hashing. Now, the IT director wants to replace the linked lists in your project with hash sets and maps.

In addition, the brokerage office would like help their FundManagers identify specific stocks as either taxable or not taxable. Therefore, they would like to replace your prior reports with a report on this.

Program Requirements

You will replace your FundManagerImpl and StockTradeLogImpl classes from Assn 3 to work with hash tables, instead of linked lists.

The FundManagerImpl will use a Hash Set to store FundManager objects. The hash table will be implemented as an array of FundManager objects (initialized to null when the table is created). The hash table will use the open addressing method via linear probing to resolve collisions. The array size for this implementation will be 19 (a prime number).

The StockTradeLogImpl will use a hashmap to store StockTrade objects. You will need to create a MapEntry class to implement the hashmap. Each MapEntry will be comprised of a key and a StockTrade node. The hashmap will be an array of MapEntry objects (initialized to null when the table is created).

Since the MapEntry value is a StockTradeNode, it can be used as a reference to a linked list. So, if there are multiple entries that map to the same index, the collisions will be resolved by using the chaining method, adding each entry to the top of the linked list at that index. This means that each StockTrade object that maps to the same index (via the hashcode) will be stored in a linked list at that index. The array size for this implementation will be 17 (another prime number).

See the last page of this requirements document for diagrams of the hash tables.

You will create your own hashing algorithms for this assignment. Remember the hashcode method that was generated for you in week 1? Modify this method for each of your domain classes.

Create a hashcode for a FundManager object in the FundManagerImpl hash table by extracting the last 5 digit characters from the FundManager license number, converting them to an integer, and then using the modulus operator, so that the value will map correctly to array indexes. For example, the license number of CCC12233, will hash to: 12233 mod 19 = 16 (maps to index 16)

Create a hashcode for a StockTrade object in the StockTradeLogImpl hash table by adding the ASCII/Unicode values of each character in the stockSymbol. After adding them, use the modulus operator, so that the value will map correctly to an array index. For example, the StockSymbol of CCDD will hash to:

67 + 67 + 68 + 68 = 270 mod 17 = 15 (maps to index 15)

The input file of FundManagers and StockTrade listings will remain the same as used in the previous assignments, except that you can now assume all data will be valid. So there will no longer be any need to validate and remove incorrect data.

You also will not need to worry about removing StockTrades or FundManagers. Concentrate on adding the objects to the respective HashSet/HashMap. You will need to remove the code in your main that removes the objects.

Read the input file and use the correct hashCode to place each FundManager/StockTrade object into the correct location in one of the hash tables. Then display the contents of each hash table as follows:

Add a displayHash() method to both FundManagerImpl and StockTradeLogImpl. These methods will first display a header:

FundManager Hash Table:            OR           StockTrade Hash Table:

and will then display where each FundManager/StockTrade object is stored in the hash table. An example is shown at the end of the assignment

NOTE: The input in the example will provide collisions on both the FundManager and StockTrades HashSet/HashMap. You may use it to test your code. However, you are expected to provide your own data input files with a minimum of five FundManagers, each with at least two StockTrades. Your data needs to be as such to cause some collisions.

Note that your FundManagerImpl and StockTradeLogImpl will no longer use remove methods (because no data will be removed from the hash tables). Instead, they will use add and find methods.

The add methods will be used to place the FundManager and StockTrade objects into their hash tables.

The find method in the FundManagerImpl class will search for a FundManager based on the FundManager license number. It will return a reference to the found FundManager object, or will return null if the FundManager is not in the hash table.

The find method in the StockTradeLogImpl class will search for a StockTrade based on the stockSymbol. It will return a reference to the found StockTrade object, or will return null if the StockTrade is not in the hash table.

You will not need to create any of the reports that you created in the past assignments. So you can remove the calls that created those reports from your main method.

Instead, the brokerage office wants you use the hash tables to create a new report of taxable/not taxable stocks by FundManager for them. The office will provide a simple flat file of FundManager license numbers and StockTrade stockSymbols, for all of the FundManagers in the office who requested a report on their taxable/not taxable stocks.

Each line of the file will contain a FundManager license number and a list of one or more StockTrade stockSymbols that the FundManager would like to check taxable/not taxable status on.

For example (this is using the sample data at the end of the assignment):

LMN11111 LMN XXXX
MMM11111 MMM
ABC11111 ABC

This file, called FundManagerRequests.txt, will be located in the input folder.

When reading the data in this file:

Use a hash code to find the FundManager license number in your FundManagerImpl hash table

Use a hash code find each StockTrade stockSymbol your StockTradeLogImpl hash table and for each, determine if the StockTrade is taxable/not taxable.

Replace the old create report method in PrintImpl with a method that will generate a new report to be written to an output file named assn5salesReport.txt, which will be located in the output folder of the project.

Sample report output:

FundManager LMN11111, George Harrison
StockTrade LMN is NOT TAXABLE
StockTrade XXXX is NOT TAXABLE
FundManager MMM11111, Ringo Starr
StockTrade MMM is TAXABLE
FundManager ABC11111 does not exist

Note that when the FundManager does not exist, you should not search for any of the StockTrade listings on that line.

The program must follow all CS310 Coding Standards from Content section 1.9.

Additional Requirements

• Create Javadoc headers, and generate Javadoc files for each of your new implementation classes and for all new static methods in the main class. You are responsible for completing the comment headers created.

• Your original input data file (containing FundManager and StockTrade data to build the hash tables from) will still be read from the input folder in your project.

Place all test data files that you create to test your program in the input folder of your project, and name them as follows:

assn5input1.txt assn5input2.txt
(i.e. number each data file after the filename of assn5input.txt)

• Your new input data file will also be read from the input folder in your project.

Place all test data files that you create to test your program in the input folder of your project, and name them as follows:

FundManagerRequests1.txt FundManagerRequests2.txt

(i.e. number each data file after the filename of FundManagerRequests.txt)

As a group, all of your test data files should demonstrate that you have tested every possible execution path within your code, including erroneous data which causes errors or exceptions.

• Add screen shots of clean compile of your classes to the documentation folder. WARNING: Submittals without the clean compile screenshots will not be accepted.

(This means that programs that do not compile will not be accepted)

Attachment:- Camargo-Assignment.zip

Reference no: EM131870374

Questions Cloud

Discuss the two results and what this process compares : What is the present value if you invest $1500 at the onset? Compare and discuss the two results and what this process compares.
Longitudinal designs and cross-sectional designs : 1. What are the advantages of longitudinal designs and cross-sectional designs?
Interest rate is earned when investment doubles : Approximately what interest rate is earned when an investment doubles over 11.3 years?
Calculate the issue price of the bonds : Directions (20 points): Prepare your responses on a separate Excel spreadsheet as directed on the Problem Set 3 directions. Calculate the issue price of bonds
Identify specific stocks as either taxable or not taxable : In addition, the brokerage office would like help their FundManagers identify specific stocks as either taxable or not taxable.
Confidence interval for the mean height : (a) Find a 95% confidence interval for the mean height it of the whole population. (b) Find a 99% confidence interval.
What areas of the city had the highest crime rate : What areas of the city had the highest crime rate in 2016? How does this compare to areas that had the highest crime rate in 2006? Back up your answer.
Confidence interval for the mean consumption : Construct a 95% confidence interval for the mean consumption of all American families (at this income and asset level).
Mean reaction time : Find a 95 confidence interval for the mean reaction time of the whole population of drivers.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd