Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

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

The Problem:

Write 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.  FIFO method results in a profit of 1037.50

5.  LIFO method results in a loss of -12.50

6.  Profit/Loss Report for Sale of PCS

7. FIFO method results in a profit of 3250

8. LIFO method results in a profit of 3375

Input

Your program will read all transaction data from a file.

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.

Example 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     2250.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.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M9131233
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Programming Language

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

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.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As