+1-415-315-9853

info@mywordsolution.com

## Programming

 C/C++ Java DOT NET Python Assembly C Sharp Perl COBOL Visual Basic CAD/CAM Object Oriented Programming Asp.NET PHP JSP Shell Scripting Java Script Ajax CSS/HTML Joomla Wordpress Megento Photoshop DBMS PL-SQL Oracle MS-SQL MS-ACCESS My-SQL SYBASE FOXPRO Excel Programming Language Mobile Applications

Objective:

Design a class-based solution to a problem using multiple data structures.

The Problem:

You need to prepare a program to help an investor figure out which stocks to sell from his/her portfolio. In the USA, the government taxes income from investments. This is called capital gains tax. Your program will determine profit and loss on stock sales, using either of two different accounting methods:
LIFO: Last purchased is the first sold
FIFO: First purchased is the first sold.

To illustrate these methods, suppose you have the following transactions:

Stock Name    Date    Number of shares    Price per share
UMKC             June 1         100                   45.50
UMKC             June 6         100                   46.50
UMKC             June 15       100                   48.50
UMKC             June 22       100                   55.50

Now, let's say you want to sell 125 shares of UMKC stock. You can choose to sell either the oldest or the newest shares. Today's price is \$54.00/share. Under the FIFO method, the 125 shares sold are considered to have cost \$5712.50 (100 shares at \$45.50 and 25 shares at \$46.50), earning a profit of \$1037.50 for reporting taxable income to the IRS. Under the LIFO method, the 150 shares sold cost \$6762.50 (100 shares at \$55.50 and 25 at \$48.50), which means you will report a loss of \$12.50 to the IRS.

The program will allow for the following activities:

1) Stock Purchase--add the number of shares and cost to the portfolio list for that stock in the portfolio. If current portfolio does not have the stock already in inventory, the stock is added to the stock list and the shares added to its inventory.

2) Stock Sale-- deletes the specified number or shares from the portfolio and generates a report ("report.txt") of the accounting method (FIFO, LIFO) that results in the minimum profit (or maximum loss). The method that produces the desired results is also noted as part of the output for this option.

The report file should look like the following:
3. Profit/Loss Report for Sale of UMKC
4. ======================================================
5. FIFO method results in a profit of 1037.50
6. LIFO method results in a loss of -12.50
7.
8. Profit/Loss Report for Sale of PCS
9. ======================================================
10. FIFO method results in a profit of 3250
11. LIFO method results in a profit of 3375

If the sale results in a zero inventory for that stock, the stock is to be deleted from your portfolio.

Input

Each line of the transaction file will include

• stock symbol
• action to be taken (char 'B' or 'S' to indicate a buy or sell)
• the number of shares bought or sold
• the price paid or received.

ex file contents:

IBM B 100 100.00
PCS B 100 100.00
PCS B 75 95.00
IBM B 100 90.00
IBM S 150 95.00
CERN B 200 80.00
PCS S 150 120.00

Output

For all valid transactions, print the transaction to the output file(output3.txt). After each valid transaction, print the total holdings of the portfolio.

Sample output:

Transaction:  CERN  B    200      80.00
Total Holdings:
Name  #Shares  LIFO Value  FIFO Value
CERN      200     1600.00      1600.00
IBM        50       5000.00       4500.00
PSC        25      2500.00        250.00
============================================

If a transaction lists a sale of a given stock which is either not in the portfolio, or there are not enough shares owned, then print the transaction to an error file(errors3.txt).

Programming Requirements

Your Portfolio of sorted stock objects must be implemented as a linked list. The data members of a stock object must include a stack and queue (to maintain your parallel systems). For efficiency, you must store pointers to the stack and queue rather than store the stacks and queues themselves in the stock object. You may also want to keep other stock data such as LIFO current value, FIFO current value and share count as data members of a stock object. As you complete your design, other data members and methods may become necessary as well. Make sure that any additional methods you create are defined with the correct access specifier (i.e private or public). Methods for your stock object minimally should include:

1) Constructor-initialized data members. Reminder: Do not initialize data members that are themselves objects of other classes since the associated constructors will be automatically called at instantiation.

2) void addShares(int numberOfShares, double costPerShare)
//adds the number of shares purchased to the stack and queue. Updates share count, FIFO current value and LIFO current value.

3) bool removeShares(int numberOfShares)
// removes the number of shares from both the stack and the queue. Updates share count, LIFO current value and FIFO current value. The method returns true if there were enough shares in inventory to complete the sale, otherwise false is returned and no shares are removed.

4) friend ostream& operator << (ostream&, const Stock&);

The Portfolio class is to be a sorted linked list of stock objects. The minimum set of Portfolio methods include the constructor, add, remove, search and an overloaded insertion operator.

Required data structures:

• an array-based stack class

Do NOT use the STL stack or queue classes. Do NOT use a list class anywhere in this program.

You may create other classes in addition to the ones I've mentioned. You must create a UML class diagram showing your classes and their relationships to each other.

Programming Language, Programming

• Category:- Programming Language
• Reference No.:- M9723

Have any Question?

## Related Questions in Programming Language

### Construct a loop which will allow for the daily fan count

Construct a loop which will allow for the daily fan count to be entered for each game. The games number (1-4) should be part of the prompt displayed to the user. Within this loop, you will need other loop(s) to validate ...

### Now consider the outer loop of given figure consisting of

Now consider the outer loop of given figure, consisting of blocks B2, B3, B4, and B5. Let g be the transfer function for the loop body, from the entry of the loop at B2 to its exit at B5. Let i measure the number of iter ...

### Suppose you have a class cbirdsuppose you have a class

Suppose you have a class CBird Suppose you have a class CBird, as follows, that you want to use as a base class for deriving a hierarchy of bird classes: class CBird { protected: int wingSpan; int eggSize; int airSpeed; ...

### Resources appendices a amp dexamine the following

Resources: Appendices A & D Examine the following situation: Your company, Datamax, Inc., is in the process of automating its payroll systems. Your manager has asked you to create a program that calculates overtime pay f ...

### Generate code for the following three-address statements

Generate code for the following three-address statements again assuming stack allocation and assuming a and b are arrays whose elements are 4-byte values. a) The four-statement sequence x = a[i] y = b[j] a[i] = y b[j] = ...

### Write a program where you create a class called bankaccount

Write a program where you create a class called BankAccount. The BankAccount class should contain a String to store the customer name and a double to store the account balance. The BankAccount class should have two const ...

### Computer science assignmnetuse this Computer Science Assignmnet use this program

Computer Science Assignmnet use this program http://snap.berkeley.edu/snapsource/snap.html# The assignment is to create a block to simulate coin tosses in snap. The block should take in 2 parameters, the number of coin t ...

### In this programming assignment you are asked to simulate

In this programming assignment, you are asked to simulate the recursive factorial function given in the class. Your program is to be a nonrecursive version of the factorial function implemented using a stack. Your progra ...

### Assignmentwrite a program to converts temperatures between

Assignment Write a program to converts temperatures between Fahrenheit and Celsius. Your program should print a brief message describing what it does, and then prompt the user to enter "1" if they would like to convert a ...

### Wite a method to computer the following series mi 12 23

Write a method to computer the following series: m(i) = 1/2 + 2/3 + . . . + i/i + 1 Write a test program that displays the following table: I m(i) 1 0.5000 2 1.1667 . . . 19 16.4023 20 17.3546 Formulas to achieve the abo ...

• 13,132 Experts

## Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

### WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

### Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

### Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

### Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

### Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro